Skip to content
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

Missing Documentation on how to resolve migration conflicts in Github and Django #442

Open
1 task
vanessaavviles opened this issue Nov 14, 2024 · 0 comments
Assignees
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

Comments

@vanessaavviles
Copy link
Member

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

  • 1.01 git, django

Documentation Addition Notes

What's missing?

In many cases, you can resolve migration conflicts by using the rebase_migration command provided by django-linear-migrations.

  1. We're assuming you're at your branch and all migrations are applied.

  2. Run this to rebase your branch to main:

    git rebase upstream/main

    note: for people that have rerere enabled, you can temporarily disable it by passing in this option: git -c rerere.enabled=false rebase ...

  3. 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.

  4. If core/migrations/max_migration.txt does show a conflict (e.g., between core/0025 and core/0027), you'll need to undo the rebase. Run this:

    git rebase --abort
  5. 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):

    ./scripts/migrate.sh core 0024
  6. Now re-run the rebase:

    git rebase upstream/main
    # see conflicts returned
  7. Resolve code conflicts if any. (In case there's other conflicts besides the migrations)

  8. Resolve the migration conflict:

    docker-compose exec web python manage.py rebase_migration core
  9. Run all the migrations again to make sure the new ones apply cleanly:

    ./scripts/migrate.sh core
  10. Stage all the fixes:

    git add <max_migration.txt> <changed migration files> <fixed code files if any>
  11. Run pre-commit checks:

    pre-commit run
  12. Finally, continue rebase:

    git rebase --continue

Where should it go?

When would this information have been useful?

Which roles will benefit most from this information?

  • Backend/ Dev
@vanessaavviles vanessaavviles self-assigned this Nov 14, 2024
@vanessaavviles vanessaavviles moved this to 🏗In progress-actively working in P: PD: Project Board Nov 14, 2024
@vanessaavviles vanessaavviles added s: PD team stakeholder: People Depot Team size: 0.25pt Can be done in 0.5-1.5 hours role: dev lead feature: docs: PD team documentation documentation on PD team processes and architecture, etc. ready for dev lead complexity: small All steps are laid out in detail so that someone new to the project can work on it and removed role: missing size: missing feature: missing stakeholder: missing ready for dev lead complexity: missing role: dev lead labels Nov 14, 2024
@shmonks shmonks moved this from 🏗In progress-actively working to 📋Prioritized Backlog in P: PD: Project Board Nov 14, 2024
@shmonks shmonks added the good first issue Good for newcomers label Nov 14, 2024
@vanessaavviles vanessaavviles added this to the w. Ongoing milestone Nov 14, 2024
@shmonks shmonks moved this from 📋Prioritized Backlog to 🏗In progress-actively working in P: PD: Project Board Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
Status: 🏗In progress-actively working
Development

No branches or pull requests

2 participants