Missing Documentation on how to resolve migration conflicts in Github and Django #442
Labels
complexity: small
All steps are laid out in detail so that someone new to the project can work on it
feature: docs: PD team documentation
documentation on PD team processes and architecture, etc.
good first issue
Good for newcomers
ready for dev lead
s: PD team
stakeholder: People Depot Team
size: 0.25pt
Can be done in 0.5-1.5 hours
Milestone
Overview
We need to add documentation, so that developers know how to resolve migration conflicts. For example, let's say you're rebasing and the
max_migration.txt
file shows a conflict. That's a sign that the numbered migration files are conflicting as well (because they're named differently, their conflicts don't show up in git).Action Items
Resources/Instructions/Tags
Documentation Addition Notes
What's missing?
In many cases, you can resolve migration conflicts by using the
rebase_migration
command provided bydjango-linear-migrations
.We're assuming you're at your branch and all migrations are applied.
Run this to rebase your branch to
main
:note: for people that have rerere enabled, you can temporarily disable it by passing in this option:
git -c rerere.enabled=false rebase ...
Now see if there's a conflict in
core/migrations/max_migration.txt
and note the lowest migration number. We're going to use this later.If
core/migrations/max_migration.txt
does show a conflict (e.g., betweencore/0025
andcore/0027
), you'll need to undo the rebase. Run this:If previous migrations are part of the conflict, you'll need to roll the local database back to a point before them, so you can change those migrations if necessary. Run this to roll the database back to an earlier migration, before any of the migrations that are in conflict (replacing '0024' with the appropriate number):
Now re-run the rebase:
git rebase upstream/main # see conflicts returned
Resolve code conflicts if any. (In case there's other conflicts besides the migrations)
Resolve the migration conflict:
docker-compose exec web python manage.py rebase_migration core
Run all the migrations again to make sure the new ones apply cleanly:
Stage all the fixes:
Run pre-commit checks:
Finally, continue rebase:
Where should it go?
When would this information have been useful?
upstream/main
Which roles will benefit most from this information?
The text was updated successfully, but these errors were encountered: