Skip to main content

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] [--verbose] --app-name APP_NAME --last LAST --conflict CONFLICT [--commit]

Resolve duplicate migration nodes.

optional arguments:
  -h, --help           show this help message and exit
  --auto-detect        Auto-detect and fix migration errors. (Not supported)
  --verbose            Verbose output
  --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.
  --commit             Commit the changes made.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-migration-resolver-hook-0.0.5.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file django-migration-resolver-hook-0.0.5.tar.gz.

File metadata

  • Download URL: django-migration-resolver-hook-0.0.5.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

File hashes

Hashes for django-migration-resolver-hook-0.0.5.tar.gz
Algorithm Hash digest
SHA256 2f929dac7ab8f8fa8a0e5438eefe8156c36876eae269df4c093c5903a97d5cb9
MD5 1a0c96babed61c8724b00136abf46ce4
BLAKE2b-256 0c2f23c4b3763a5c6e081e630c388dfa38dd3a5ba27260ff4307604ec2cde864

See more details on using hashes here.

Provenance

File details

Details for the file django_migration_resolver_hook-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: django_migration_resolver_hook-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

File hashes

Hashes for django_migration_resolver_hook-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 892768e75a713a44ab09690a6803272f38b24bfc6b53e617d89369c164bf63b6
MD5 1c8d47d83d45efbaeb1bf4eec150eeef
BLAKE2b-256 299f563bd90a79fbecfc4e8d9946cac8b1104bbef6b0c5e15591bc61bd8a9d2d

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page