Automate the destruction and re-creation of django databases
Compatible with Django 1.8+
For 1.7 compatibility use django-zap==0.0.6
Automates the destruction and recreation of django databases.
Currently only supports local postgres databases. Feel free to add more backends.
In the early stages of development when your models are heavily in flux, you want to be frequently dropping and recreating the database before re-running django’s syncdb command. This tool uses the database settings in your settings file to prevent you having to duplicate them in some separate database drop/create script.
Just add zap to your installed apps.
A new django management command will appear: zap_and_create_db.
Help is at python manage.py zap_and_create_db --help but the TL;DR is that you can run it without arguments and it’ll drop the user and database, then recreate them. Run it with --migrate and it’ll also run manage.py migrate.
At the moment the only backend is for linux machines running a local postgresql instance, and authentication is done using the ident rule in the pg_hba.conf, then calling psql as the postgres user.
Feel free to provide more backends or extend the one we have, perhaps to include mac support, or support for other django database engines.
Now only compatible with django 1.8+
- Replaces option_list with add_arguments
- Adds --droptest argument, which also drops the test database. This feature is aimed at people using –keepdb to speed up their test runs.
- database argument now passed to backend in support of multiple database setups.
- #3 Adds a new flag --dropconnections, disabled by default, that tells postgres to terminate all existing sessions before zapping. This is to work around an issue where third party applications open database connections upon app registry installation.
- Adds OSX detection
- Adds port option for postgres backend
- Changes working directory of postgres subprocess command to /tmp
- Update how args are parsed to allow use from call_command
- All important fix-the-bladdy-packaging release
- Initial Release