Management command to attempt Django migrations and rollback on failure
Project description
django-migrate-or-rollback
While single migrations in Django are atomic (as long as they have the default atomic=True
),
a group of migrations are not. Thus, when running migrations, you can have a partial
failure where some but not all of your migrations succeed. This library fixes that.
This library provides a new management command migrate_or_rollback
. It's a drop-in
replacement for the Django builtin management command migrate
. Here's how it works:
- Checks your database and current migration files for the latest migrations run per Django app.
- Runs migrations as normal.
- If migrations fail, it rolls back to the migrations identified in step 1.
Instalation
pip install django-migrate-or-rollback
Alternatively, add django-migrate-or-rollback
to your requirements.txt file.
Then, add "django_migrate_or_rollback"
to your INSTALLED_APPS
in settings.py, like so:
# settings.py
INSTALLED_APPS = [
# ...
"django_migrate_or_rollback",
]
Usage
Run python managage.py migrate_or_rollback
instead of the standard migrate
command.
In particular, you should use migrate_or_rollback
in place of migrate
in your deployment scripts or CI/CD system.
migrate_or_rollback
has all of the same options as migrate
, such as the --noinput
flag.
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 Distribution
Built Distribution
Hashes for django-migrate-or-rollback-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b45f85f90c6d2744c26307a4233139d82d8a331de870acc22f321fc3fcff6a4 |
|
MD5 | a051b8d30ef555a7b7271c5b259e6cfc |
|
BLAKE2b-256 | aa1e6a649249e4a0980a5593b1d96fd814c39aea72b88130e19b6772c1040d65 |
Hashes for django_migrate_or_rollback-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b02315210ed2f0b9ed5c80bb6230430ecdc43b0c3d86e890b984b9fc8345c05 |
|
MD5 | 84bab8b8d0530a77075814a0fc9e3c27 |
|
BLAKE2b-256 | 7d443eff30b4fe2c8ebd3a35ae5c459893864e02f511b8affb5c0836e927b107 |