Fix migrations when restoring prod database, sort deterministically when ordering property|tax states#5261
Open
nllong wants to merge 6 commits into
Open
Fix migrations when restoring prod database, sort deterministically when ordering property|tax states#5261nllong wants to merge 6 commits into
nllong wants to merge 6 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces guarded “repair” migrations to restore missing primary key and unique constraints in production databases where historical migrations were recorded as applied but constraints were not actually present, preventing later foreign key migrations from succeeding.
Changes:
- Adds an
orgsrepair migration to restoreorgs_organization/orgs_organizationuserprimary keys and theunique_user_for_organizationuniqueness constraint. - Updates seed migration
0250to proactively repair missing constraints before adding fields/foreign keys. - Adds a follow-up seed repair migration
0254to fix already-migrated databases past0250.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
seed/migrations/0254_repair_referenced_primary_keys.py |
New seed repair migration to (idempotently) restore missing PKs needed by later FKs. |
seed/migrations/0250_remove_goal_current_cycle_goal_partner_note_and_more.py |
Adds guarded constraint repair SQL ahead of schema changes to avoid FK failures on broken prod restores. |
seed/lib/superperms/orgs/migrations/0046_repair_organizationuser_constraints.py |
New orgs repair migration restoring PKs and expected uniqueness constraint. |
.spelling.dic |
Adds a handful of allowed dictionary words used in the repo/tooling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Any background context you want to provide?
When trying to restore the production database, a couple issues appeared with the migrations around primary key constraints.
What's this PR do?
seed_cycle, and seed_goal.
How should this be manually tested?
ideally restore prod database and make sure things hold together.
What are the relevant tickets?
Screenshots (if appropriate)