rebase-migration: Make it possible to handle chains of migrations. #343
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Commit 1
:Previously, the rebase_migration command was not able to rebase chains of migrations in a single app.
This commit introduces a new flag -- "--new" which basically is used for the first migration you create in a commit , and it wipes out your migration history in max_migration.txt, and writes up that first migration in the first line. Any further migrations added without the flag are simply added under each other in the max_migration.txt.
This would allow the rebase_migration command to access the chain of migrations that need to be rebased in a commit, and will rebase them accordingly.
eg:
./manage.py makemigrations --new
in your new commit would wipe out the existing list inmax_migration.txt
and write up the first migration created in the first line. Subsequent migrations don't require you to add this flag, and they are added under each other in themax_migration.txt
.While rebasing,
self.last_migration_number
would be initialized to the last merged migration, and based on these rebased migrations are renumbered, and eventuallyself.last_migration_number
is updated.Added necessary tests, and also tested manually in a project requiring rebasing of 3 migrations in an app.
Fixes #27
cc @timabbott