Resolve migration conflicts.
Project description
django-migration-resolver-hook
Migration resolver for django, ensures that the migration nodes always stays in sync regardless of remote changes.
Installation
$ pip install django-migration-resolver-hook==0.0.1
Poetry
poetry add -D django-migration-resolver-hook
Using extras
setup(
...
extras_require={
'development': [
...
'django-migration-resolver-hook==0.0.1',
...
]
},
)
Usage
Scenario
Remote
|--- migrations
|---- ...
|---- 0007_auto_20200112_2328.py # Shared between remote and local repo
|---- 0008_auto_20200113_4328.py # Only exists on remote
|---- 0009_auto_20200114_4532.py
|---- 0010_auto_20200115_1632.py
Local repo
|--- migrations
|---- ...
|---- 0007_auto_20200112_2328.py # Shared between remote and local repo
|---- 0008_auto_20200114_5438.py # Only exists locally which raises duplicate migration nodes errors.
Since this is now out of sync with the remote branch to sync changes reseeding the migration run:
$ migration_resolver --app-name my_app --last 0010_auto_20200115_1632 --conflict 0008_auto_20200114_5438 --commit --verbose
Output
Fixing migrations...
Updating the conflicting migration file 0008_auto_20200114_5438.py
Succefully updated: 0008_auto_20200114_5438.py.
Renaming the migration file from 0008_auto_20200114_5438.py to 0011_auto_20200114_5438.py
Successfully renamed the migration file.
[my-test-branch c18fca41e] Resolved migration conflicts for 0008_auto_20200114_5438.py → 0011_auto_20200114_5438.py
1 file changed, 1 insertion(+), 1 deletion(-)
rename my_app/migrations/{0008_auto_20200114_5438.py => 0011_auto_20200114_5438.py} (99%)
For more options
$ migration_resolver --help
Usage: migration_resolver [-h] [--auto-detect AUTO_DETECT] --app-name APP_NAME
--last LAST --conflict CONFLICT
Fix vcs errors with duplicate migration nodes.
optional arguments:
-h, --help show this help message and exit
--auto-detect AUTO_DETECT
Auto-detect and fix migration errors. (Not supported)
--app-name APP_NAME App Name
--last LAST The glob/full name of the final migration file.
--conflict CONFLICT The glob/full name of the final migration file with
the conflict.
Using vsc (git/mercurial) when the remote has a migration files that conflict with previous migrations you have locally.
TODO:
- Auto detect and resolve errors with migration nodes.
- Add support for database unapply migration for case of applied migrations.
- Add support to rollback any changes if there are failures in the chain of operations.
- VCS support right now only git is supported (extend to mercurial).
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
Close
Hashes for django-migration-resolver-hook-0.0.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c07c7bf1f875d1f41100caa6cf126e5b18a716176d09fca995ff52485e191a01 |
|
MD5 | 0427810c41678d59a7f50cef75af6d5d |
|
BLAKE2b-256 | 50d010eba79e36bdc6d29629f93ec0f516d73cdee548e031550e01d34880e41f |
Close
Hashes for django_migration_resolver_hook-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2abe4955891bd53ee003e8dc5ff448cceaab7f7b5dc406ba86343de2037f997 |
|
MD5 | b6373b1f90a8d186e8767e0388e3a952 |
|
BLAKE2b-256 | 7b2155ae100b286085d71d54b059604eb3eabbb95f824c9906b6647280ec9960 |