Skip to main content

Smart reversion of Django migrations based on Git diff

Project description

Packaging: poetry Code style: black Join the chat at https://gitter.im/django-unmigrate PyPi version Downloads

If you are in a complex Django project, sometimes you will find yourself switching between multiple branches, some of which can add a number of database migrations. Before switching back to master you will have to unapply all migrations that are specific to the current branch. To make things worse, in order to unapply Django migrations, you have to enter the migration that comes right before the first migration of the current branch. It’s not that big of a deal, Django is smart enough to let you use an unambiguos prefix of any migration, but with this package you can speed things up a little bit.

While standing on any branch, you can use:

python manage.py unmigrate master

Or if it’s going to be master anyways, this will suffice:

python manage.py unmigrate

And that’s it!

A little deeper

Ok, you can do more than that.

Do you need to unapply your migrations from the same branch, a few commits behind? Here’s how:

python manage.py unmigrate HEAD~5
python manage.py unmigrate af332b
python manage.py unmigrate v1.33.7

If you only want to see the target migrations:

python manage.py unmigrate --dry-run

And if you just want to play with this, go ahead and unapply your migrations with fake. Just don’t forget to apply them again:

python manage.py unmigrate --fake
python manage.py migrate --fake

Contributing

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-unmigrate-0.1.1.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

django_unmigrate-0.1.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file django-unmigrate-0.1.1.tar.gz.

File metadata

  • Download URL: django-unmigrate-0.1.1.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for django-unmigrate-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d2c7de71b8361480043b2c90eb55b68d821e381424315a84016c77ab53231471
MD5 2a2e88d2b61e1333ad0b460c46c2ded3
BLAKE2b-256 98defad04019bd6cf571f2340069f6b2e9aad28efb51e740db180d1f8eef30da

See more details on using hashes here.

File details

Details for the file django_unmigrate-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: django_unmigrate-0.1.1-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.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for django_unmigrate-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5fa8a33f232e3673d61b90e04ceb40f2624bda21583fe131319abab073c6f3f2
MD5 de18ca7629d415659d542a63bdd73563
BLAKE2b-256 f77c1c57c70288781a8abc3b0d711aa49f598d4a7d0e8911f2512f1d1cae26a9

See more details on using hashes here.

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