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 Build status Code coverage 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

  • Join the discussion at https://gitter.im/django-unmigrate/community.

  • PRs are welcome! If you have questions or comments, please use the link above.

  • To run the test suite run make or make coverage. The tests for this project live inside a small django project called dunm_sandbox. Beware! This package uses Git to function, therefore, the tests expect a number of commit hashes inside this repository to remain stable in order to function. See this meta file for further details.

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.2.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

django_unmigrate-0.1.2-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django-unmigrate-0.1.2.tar.gz
  • Upload date:
  • Size: 5.7 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.2.tar.gz
Algorithm Hash digest
SHA256 07095e8f645b467f6ce175ecfa610f6a85fe92bf3511d793f31cf50e7853cc33
MD5 47d7bbb37d6bc4b6a03ccb5904c77f15
BLAKE2b-256 c21596d2ed0dc9d8bbd51dd71c350223fcdb125572cdacacf3ddceab72c971af

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_unmigrate-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.2 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2d5077064869dc84098d16431ce5f7f52cedef347188c39bcd1c2466964b218f
MD5 3d3acc585008f490947dac9d63887591
BLAKE2b-256 22a4bc0dd17b9c83b8430090a567f3da4e6f053fea44c0a6ce8fc837d6c5d023

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