All Projects → lorinkoz → django-unmigrate

lorinkoz / django-unmigrate

Licence: MIT license
Smart reversion of Django migrations based on Git diff

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to django-unmigrate

strong migrations
Catch unsafe migrations in your Elixir application
Stars: ✭ 58 (-10.77%)
Mutual labels:  migrations
db-migrator.go
DB migrations. CLI and Golang
Stars: ✭ 13 (-80%)
Mutual labels:  migrations
butterfly
Application transformation tool
Stars: ✭ 35 (-46.15%)
Mutual labels:  migrations
migrate-rethinkdb
A migration tool for rethink db
Stars: ✭ 16 (-75.38%)
Mutual labels:  migrations
upscheme
Database migrations and schema updates made easy
Stars: ✭ 737 (+1033.85%)
Mutual labels:  migrations
pg-migrate
PostgreSQL migration tool
Stars: ✭ 39 (-40%)
Mutual labels:  migrations
migrations
Migrations is a database migration tool that uses go's database/sql from the standard library
Stars: ✭ 17 (-73.85%)
Mutual labels:  migrations
flask-db
A Flask CLI extension to help migrate and manage your SQL database.
Stars: ✭ 56 (-13.85%)
Mutual labels:  migrations
krab
Krab is a migration and automation tool for PostgreSQL based on HCL syntax
Stars: ✭ 15 (-76.92%)
Mutual labels:  migrations
mongodb-migrations
Managed migration support for MongoDB
Stars: ✭ 22 (-66.15%)
Mutual labels:  migrations
migrant
Migration management for PostgreSQL/SQLite/MySQL
Stars: ✭ 85 (+30.77%)
Mutual labels:  migrations
metana
Abstract task migration tool written in Go for Golang services. Database and non database migration management brought to the CLI.
Stars: ✭ 61 (-6.15%)
Mutual labels:  migrations
shyft
⬡ Shyft is a server-side framework for building powerful GraphQL APIs 🚀
Stars: ✭ 56 (-13.85%)
Mutual labels:  migrations
serverless-typeorm-migrations
Database migrations for AWS Lambda and RDS using TypeORM Migrations
Stars: ✭ 38 (-41.54%)
Mutual labels:  migrations
laravel-fk-migration
Helpful base migration for creating all your foreign key without worrying about the order of your migrations.
Stars: ✭ 37 (-43.08%)
Mutual labels:  migrations
apistar alembic migrations
Alembic migrations for apistar
Stars: ✭ 18 (-72.31%)
Mutual labels:  migrations
slim migrations
Let's you write slightly slimmer Rails migrations.
Stars: ✭ 14 (-78.46%)
Mutual labels:  migrations
fulcro-sql
Web server SQL components, and support for running Om Next/Fulcro graph queries against an SQL database.
Stars: ✭ 18 (-72.31%)
Mutual labels:  migrations
liquigraph
Migrations for Neo4j
Stars: ✭ 122 (+87.69%)
Mutual labels:  migrations
migrant lib
Embeddable migration management
Stars: ✭ 22 (-66.15%)
Mutual labels:  migrations

django-unmigrate

Packaging: poetry Code style: black 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. In order to unapply these, you will have to enter the migration that comes right before the first migration of the current branch. If two or more apps are involved, you will have to do that for each one of them.

If you leave your migration names unchanged, inferring the name of the right migration to target is not too difficult, because they are prefixed by default with a sequential number. Django also helps, being smart enough to let you use an unambiguous prefix of any migration name. Add a merge migration and the numbers will no longer be so obvious. Or if you have renamed your migration files to drop the sequential numbers you will have to do the search manually.

With django-unmigrate you can speed up the process.

Usage

Add django_unmigrate to your INSTALLED_APPS. This is required to make the unmigrate management command available.

Then, while standing on any branch, you will be able to 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~12
python manage.py unmigrate b13553d
python manage.py unmigrate v1.33.7

Or if you only want to see the target migrations, do:

python manage.py unmigrate --dry-run

Finally, if you just want to play with the app with no actual modifications in the database, go ahead and unapply your migrations with fake. Just don't forget to apply them again at the end:

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

Contributing

  • Join the discussion at https://github.com/lorinkoz/django-unmigrate/discussions.
  • 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 be present and remain stable in order to function. See this meta file for further details.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].