Skip to content

Fix branched Alembic migration chain#100

Merged
garland3 merged 1 commit intofeature/user-annotations-collectionsfrom
copilot/fix-alembic-migration-path
Apr 14, 2026
Merged

Fix branched Alembic migration chain#100
garland3 merged 1 commit intofeature/user-annotations-collectionsfrom
copilot/fix-alembic-migration-path

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

Two migrations both declared down_revision = '20260220_0003', creating a fork that Alembic cannot apply linearly. 20260331_0005 also skipped 20260315_0004 entirely.

Before (broken):

0003 ──┬── 20260306_0004 (add_image_groups)
       └── 20260315_0004 (add_annotations_collections_audit)  ← orphaned branch
20260331_0005 down_revision → 20260306_0004  ← skips audit migration

After (linear):

0003 → 20260306_0004 → 20260315_0004 → 20260331_0005

Changes:

  • 20260315_0004_add_annotations_collections_audit.py: down_revision '20260220_0003''20260306_0004'
  • 20260331_0005_add_project_archive.py: down_revision '20260306_0004''20260315_0004'

@garland3 garland3 marked this pull request as ready for review April 14, 2026 01:52
Copilot AI review requested due to automatic review settings April 14, 2026 01:52
@garland3 garland3 merged commit 2eff3a5 into feature/user-annotations-collections Apr 14, 2026
3 checks passed
@garland3 garland3 deleted the copilot/fix-alembic-migration-path branch April 14, 2026 01:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a branched Alembic migration graph by re-pointing down_revision values so the backend schema migrations apply in a single linear order (avoiding multiple-head/fork issues during alembic upgrade head).

Changes:

  • Update 20260315_0004 to depend on 20260306_0004 (instead of 20260220_0003).
  • Update 20260331_0005 to depend on 20260315_0004 (instead of 20260306_0004).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
backend/alembic/versions/20260315_0004_add_annotations_collections_audit.py Re-parents the audit/annotations migration so it no longer creates a fork off 0003.
backend/alembic/versions/20260331_0005_add_project_archive.py Re-parents the project-archive migration so it no longer skips the audit/annotations migration.

Comment on lines 11 to 13
revision = '20260331_0005'
down_revision = '20260306_0004'
down_revision = '20260315_0004'
branch_labels = None
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module docstring still says Revises: 20260306_0004, but down_revision is now 20260315_0004. Please update the docstring header so it matches the actual Alembic dependency chain (helps when reading alembic history --verbose).

Copilot uses AI. Check for mistakes.
Comment on lines 12 to 14
revision = '20260315_0004'
down_revision = '20260220_0003'
down_revision = '20260306_0004'
branch_labels = None
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module docstring header still says Revises: 20260220_0003, but down_revision is now 20260306_0004. Please update the docstring so it reflects the true parent revision (otherwise migration history output and manual audits are confusing).

Copilot uses AI. Check for mistakes.
# revision identifiers, used by Alembic.
revision = '20260315_0004'
down_revision = '20260220_0003'
down_revision = '20260306_0004'
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR modifies down_revision of existing migrations. The repo docs explicitly call out “Never modify applied migrations” and suggest resolving conflicts via a merge revision (alembic merge heads). If these revisions may already be applied in any shared/staging/prod database, consider using a merge migration (or a new follow-up revision) instead of rewriting history, or at least document the required recovery steps (e.g., stamping/merging) for environments already upgraded.

Suggested change
down_revision = '20260306_0004'
down_revision = '20260220_0003'

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants