Skip to content

fix(alembic): linearize two migration heads onto 3f9a1c7b2e04#12978

Merged
fregataa merged 3 commits into
mainfrom
fix/alembic-multiple-heads-3f9a1c7b
Jul 21, 2026
Merged

fix(alembic): linearize two migration heads onto 3f9a1c7b2e04#12978
fregataa merged 3 commits into
mainfrom
fix/alembic-multiple-heads-3f9a1c7b

Conversation

@agatha197

Copy link
Copy Markdown
Contributor

Summary

main has two alembic heads, so scripts/check-multiple-alembic-heads.py exits 1:

Detected head revisions: b988f01b17a1, a1c4e7b93f22

Both migrations branched off the same parent 3f9a1c7b2e04 and merged independently:

Revision Added by Merged
b988f01b17a1 (fair-share uniqueness) #12818 10:20
a1c4e7b93f22 (kernel history read perms) #12869 10:23

Fix

Per src/ai/backend/manager/models/alembic/README.md — keep a single linear head, never create merge migrations, fix down_revision pointers instead.

Reparent the later-merged a1c4e7b93f22 onto the earlier b988f01b17a1. The two migrations are independent (an RBAC permission seed vs. a uniqueness-constraint change), so reordering is safe.

3f9a1c7b2e04 -> b988f01b17a1 -> a1c4e7b93f22   (single head)

Test plan

  • python3 scripts/check-multiple-alembic-heads.pyDetected head revisions: a1c4e7b93f22, exit 0
  • pants fmt lint --changed-since=HEAD clean

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 21, 2026 03:27
@agatha197
agatha197 requested a review from a team as a code owner July 21, 2026 03:27
@github-actions github-actions Bot added size:XS ~10 LoC comp:manager Related to Manager component require:db-migration Automatically set when alembic migrations are added or updated labels Jul 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Linearizes the Manager Alembic migration chain to restore a single head.

Changes:

  • Reparents a1c4e7b93f22 onto b988f01b17a1.
  • Updates the migration docstring accordingly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

agatha197 added a commit that referenced this pull request Jul 21, 2026
Satisfies the timeline-check towncrier gate on #12978.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@fregataa fregataa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please add a new merge revision rather than changing an existing revision

agatha197 and others added 3 commits July 21, 2026 13:43
PRs #12818 (b988f01b17a1) and #12869 (a1c4e7b93f22) each branched a
migration off 3f9a1c7b2e04 and merged independently, leaving two alembic
heads and failing scripts/check-multiple-alembic-heads.py.

Per the alembic README (keep a single linear head; never merge), reparent
the later-merged a1c4e7b93f22 (kernel history perms) onto the earlier
b988f01b17a1 (fair-share uniqueness). The two migrations are independent,
so ordering is safe. Chain is now:
  3f9a1c7b2e04 -> b988f01b17a1 -> a1c4e7b93f22

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Satisfies the timeline-check towncrier gate on #12978.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Revert the earlier reparent of a1c4e7b93f22 (its down_revision goes back
to 3f9a1c7b2e04) and instead add an empty merge migration 577c7a215934
whose down_revision is the tuple of the two heads.

Per the alembic guardrails, when main itself has two or more heads the
correct fix is an empty merge migration, not editing the diverged
(possibly already-released) migrations' down_revision. Chain is now:
  3f9a1c7b2e04 -> b988f01b17a1 -> 577c7a215934
  3f9a1c7b2e04 -> a1c4e7b93f22 -> 577c7a215934

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@fregataa
fregataa force-pushed the fix/alembic-multiple-heads-3f9a1c7b branch from b049721 to 314cb3b Compare July 21, 2026 04:53
@github-actions github-actions Bot added size:S 10~30 LoC and removed size:XS ~10 LoC labels Jul 21, 2026
@fregataa
fregataa enabled auto-merge (squash) July 21, 2026 04:54
@fregataa
fregataa merged commit 66fde7b into main Jul 21, 2026
36 checks passed
@fregataa
fregataa deleted the fix/alembic-multiple-heads-3f9a1c7b branch July 21, 2026 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:manager Related to Manager component require:db-migration Automatically set when alembic migrations are added or updated size:S 10~30 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants