-
-
Notifications
You must be signed in to change notification settings - Fork 23
rebase-migration: Make it possible to handle chains of migrations. #343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
df25516
to
a0b5c61
Compare
@adamchainz we are thinking of using this in @zulip. Since we would be quite often making multiple migrations in same app in a commit this feature would be important for us. Let me know what you think about this PR/approach. Thanks! |
@adamchainz |
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, 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. Fixes adamchainz#27
Thank you for your work here and in the other PR. I haven't found the time to review it fully yet. Here are some initial thoughts. I think Putting multiple migration names in Anyway, I will try have a play around with the PR soon. I have been doing some other updates here so a bit more familiar with the code right now. |
@adamchainz Thanks for responding! Your thoughts are absolutely make sense. Thinking about this a bit more, I could come up with a modified approach which might address your concerns. Please let me know your thoughts! 1.
|
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