-
Notifications
You must be signed in to change notification settings - Fork 15
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
Fix migration issues with django native "squashmigrations" command #34
Fix migration issues with django native "squashmigrations" command #34
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested them in different scenarios (with existing, new migration state). Looks good to me
I'll approve and merge this one @diogosilva30 (cc @moritz89 ), but we need to create an issue for the future... ... to remind us to convert the squashed migration into a normal one and leave the Django gods happy with us. 😇 According to the official documentation:
Thanks for this! |
@diogosilva30 before approving, I'd strongly recommend giving a proper name to the migration file, instead of the autogenerated one (since it will not be useful for humans in the future):
|
@uw-rvitorino I have renamed the migration to "redo_migrations_0001to0005". The resulting file is |
@moritz89 Please review this new PR.
I have looked for a more native solution to the migration problem, and have found the django
squashmigrations
command. This command creates a new migration that replaces existing ones.This safely keeps all existing migrations for existing production systems, and creates a new
0001_squashed_0005_auto_20211231_1702.py
for new deployments. With this change we encountered no problems in a existing system and new systems.Once all existing production systems have applied this migrations, the old ones can be safely deleted if needed.
This solution was discussed and approved with @rjfv @ubi-rvitorino
Please review Django Documentation on this command:
https://docs.djangoproject.com/en/4.1/topics/migrations/#squashing-migrations