`zeromigrations` command for django to set migrations zero with backup feature
Project description
As the project grows up, the number of migration files increases over time. As a result, running them can consume a lot of time, specifically when you are running your tests.
zeromigrations is a command to reset migration files (I SUGGEST NOT TO RUN IT ON PRODUCTION). It basically runs 4 commands:
migrate --fake {app_name} zero for each app.
Remove old migration files, as new migrations is going to be generated.
makemigrations to generate initial migration file.
migrate --fake-initial to fake generated initial files.
But besides that, this command can make a backup to restore in case of any failure.
Note that migrate --fake command only runs for your own apps and django apps like contenttype and third-party apps are excluded.
Installation
First install the package:
pip3 install django-zeromigrations
Then add it to your INSTALLED_APPS:
INSTALLED_APPS = [
...
"zero_migrations"
]
Usage
First, run the command:
python manage.py zeromigrations
I suggest to make a backups from both your migrations and django_migrations table (just in case).
1- make backup
2- restore last backup
3- just proceed
If you choose 1- make backup, it would make a backup then zero migrations.
If you choose 2- restore last backup, it tries to restore the latest backup that can be found. If not backup found, it would raise an error.
If you choose 3- just proceed, it assumes that you already have your own backup and start setting migrations zero.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for django_zeromigrations-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c087e1a21c69430ea75b2f3222ffdcbef86a09e0dfc05cebd736ea1cb9bb5b4 |
|
MD5 | c2ff797575efb5f97b40d34ad09088d5 |
|
BLAKE2b-256 | 0a697291be685bc235c8ffd598289ce2f9f91209658f72a7e3b7fa8368d3bc69 |