Quick tip, if you want to start fresh on your self hosted Unifi Controller instance, there is a simple command to just purge and reset the database and settings to factory defaults. Just ssh into your Unifi Controller instance on Ubuntu or Debian and enter as superuser:
systemctl stop unifi && perl -pe 's/is_default\=false/is_default=true/g' -i /var/lib/unifi/system.properties && systemctl start unifi
No need to apt uninstall anything or do complicated purges 🙂 Enjoy!