Skip to content

feat(api): split migration chains at the alignment point#4680

Open
jp-agenta wants to merge 7 commits into
chore/drop-legacy-tablesfrom
feat/migration-chain-split
Open

feat(api): split migration chains at the alignment point#4680
jp-agenta wants to merge 7 commits into
chore/drop-legacy-tablesfrom
feat/migration-chain-split

Conversation

@jp-agenta

@jp-agenta jp-agenta commented Jun 12, 2026

Copy link
Copy Markdown
Member

Context

The OSS and EE alembic core chains are historically different and immutable, which makes an in-place OSS→EE switch impossible: an OSS database's alembic_version holds ids the EE chain cannot resolve. The convergence stack (#4671#4676) brings the schemas to parity; this PR splits the migration chains at that point so the editions never re-fork and adoption becomes structurally possible. Design: docs/designs/oss-ee-convergence/migration-chains-and-edition-switch.md.

Changes

  • Both legacy core chains end with one empty align revision, a00000000000, same id in both editions with per-edition parents. The legacy chains park there forever; alembic_version becomes a frozen artifact.
  • New shared chain at oss/databases/postgres/migrations/core_oss/ tracked in alembic_version_oss. It runs in both editions; EE executes it from the oss/ tree its images already ship, so shared migrations exist exactly once.
  • New EE-only chain at ee/databases/postgres/migrations/core_ee/ tracked in alembic_version_ee. All future EE-only schema lives here; it may reference only EE tables and forever-stable shared PKs.
  • Runner order with asserts: legacy chain (must be parked at align) → shared chain → EE chain (EE only) → tracing. Both new chains resolve their alembic config from the module location; there is no path env var to misconfigure.
  • Both new chains start with empty root markers, followed by one no-op proof revision each (o00000000002 shared, e00000000002 EE-only) so the version tables can be watched moving independently. The OSS→EE adoption migration lands in the EE chain in feat(api): OSS-to-EE adoption migration on the EE chain #4683.

Tests / notes

🤖 Generated with Claude Code

@vercel

vercel Bot commented Jun 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Ready Ready Preview, Comment Jun 14, 2026 3:45pm

Request Review

@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. Backend Feature Request New feature or request labels Jun 12, 2026
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b5ef26b3-2713-4c41-881a-0a209cd3c23c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/migration-chain-split

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@junaway junaway force-pushed the feat/migration-chain-split branch from 4f35d7b to 6c47e27 Compare June 12, 2026 18:40
junaway pushed a commit that referenced this pull request Jun 13, 2026
…ranch

The interim-to-final id rename of the chain-split files belongs on #4680, not
here. Rename those six files back to interim ids so #4680 can own the rename;
the adoption file keeps its final id and relinks to the interim ee proof.
junaway pushed a commit that referenced this pull request Jun 13, 2026
#4680 renames the chain-split migrations to the final ids; drop this branch's
interim revert so the stack stays at the final scheme end to end.
@github-actions

github-actions Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Preview URL https://gateway-production-7ded.up.railway.app/w
Image tag pr-4680-cef26f8
Status Failed
Railway logs Open logs
Logs View workflow run
Updated at 2026-06-14T15:46:51.101Z

@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Jun 14, 2026
@junaway junaway force-pushed the chore/drop-legacy-tables branch from a52e038 to 92530d5 Compare June 14, 2026 13:03
@junaway junaway force-pushed the feat/migration-chain-split branch from 407a0cf to 553a01a Compare June 14, 2026 13:06
junaway pushed a commit that referenced this pull request Jun 14, 2026
…ranch

The interim-to-final id rename of the chain-split files belongs on #4680, not
here. Rename those six files back to interim ids so #4680 can own the rename;
the adoption file keeps its final id and relinks to the interim ee proof.
junaway pushed a commit that referenced this pull request Jun 14, 2026
#4680 renames the chain-split migrations to the final ids; drop this branch's
interim revert so the stack stays at the final scheme end to end.
junaway pushed a commit that referenced this pull request Jun 14, 2026
…ranch

The interim-to-final id rename of the chain-split files belongs on #4680, not
here. Rename those six files back to interim ids so #4680 can own the rename;
the adoption file keeps its final id and relinks to the interim ee proof.
junaway pushed a commit that referenced this pull request Jun 14, 2026
#4680 renames the chain-split migrations to the final ids; drop this branch's
interim revert so the stack stays at the final scheme end to end.
@junaway junaway force-pushed the chore/drop-legacy-tables branch from 92530d5 to 903f73e Compare June 14, 2026 13:25
@junaway junaway force-pushed the feat/migration-chain-split branch from 8829687 to d8682ac Compare June 14, 2026 13:25
junaway pushed a commit that referenced this pull request Jun 14, 2026
…ranch

The interim-to-final id rename of the chain-split files belongs on #4680, not
here. Rename those six files back to interim ids so #4680 can own the rename;
the adoption file keeps its final id and relinks to the interim ee proof.
junaway pushed a commit that referenced this pull request Jun 14, 2026
#4680 renames the chain-split migrations to the final ids; drop this branch's
interim revert so the stack stays at the final scheme end to end.
@junaway junaway force-pushed the feat/migration-chain-split branch from d8682ac to 0145eed Compare June 14, 2026 13:59
junaway pushed a commit that referenced this pull request Jun 14, 2026
…ranch

The interim-to-final id rename of the chain-split files belongs on #4680, not
here. Rename those six files back to interim ids so #4680 can own the rename;
the adoption file keeps its final id and relinks to the interim ee proof.
junaway pushed a commit that referenced this pull request Jun 14, 2026
#4680 renames the chain-split migrations to the final ids; drop this branch's
interim revert so the stack stays at the final scheme end to end.
junaway pushed a commit that referenced this pull request Jun 14, 2026
…ranch

The interim-to-final id rename of the chain-split files belongs on #4680, not
here. Rename those six files back to interim ids so #4680 can own the rename;
the adoption file keeps its final id and relinks to the interim ee proof.
junaway pushed a commit that referenced this pull request Jun 14, 2026
#4680 renames the chain-split migrations to the final ids; drop this branch's
interim revert so the stack stays at the final scheme end to end.
@junaway junaway force-pushed the chore/drop-legacy-tables branch from e66be2c to 01b03ff Compare June 14, 2026 15:06
@junaway junaway force-pushed the feat/migration-chain-split branch from 9b2e417 to 1e0e499 Compare June 14, 2026 15:07
junaway pushed a commit that referenced this pull request Jun 14, 2026
…ranch

The interim-to-final id rename of the chain-split files belongs on #4680, not
here. Rename those six files back to interim ids so #4680 can own the rename;
the adoption file keeps its final id and relinks to the interim ee proof.
junaway pushed a commit that referenced this pull request Jun 14, 2026
#4680 renames the chain-split migrations to the final ids; drop this branch's
interim revert so the stack stays at the final scheme end to end.
@junaway junaway force-pushed the feat/migration-chain-split branch from 1e0e499 to 5bd61fd Compare June 14, 2026 15:38
junaway pushed a commit that referenced this pull request Jun 14, 2026
…ranch

The interim-to-final id rename of the chain-split files belongs on #4680, not
here. Rename those six files back to interim ids so #4680 can own the rename;
the adoption file keeps its final id and relinks to the interim ee proof.
junaway pushed a commit that referenced this pull request Jun 14, 2026
#4680 renames the chain-split migrations to the final ids; drop this branch's
interim revert so the stack stays at the final scheme end to end.
jp-agenta and others added 7 commits June 14, 2026 17:43
Both legacy core chains gain a final empty align revision (a1167e5b0001, same
id in both editions, per-edition parent) and park forever. New independent
chains take over: the shared chain under oss/databases/postgres/migrations/
core_oss (alembic_version_oss, runs in both editions; EE reads it from the oss
tree it ships) and the EE-only chain under ee/.../core_ee (alembic_version_ee).
Runners gain the new steps with an explicit at-align assert before the new
chains run; chain configs derive from the module location, so there is no
path env var to misconfigure. Roots are empty markers; the adoption migration
for OSS-to-EE switches lands in the ee chain in a follow-up.

Design: docs/designs/oss-ee-convergence/migration-chains-and-edition-switch.md
No-op revision demonstrating the split works end to end: replaying either
edition moves alembic_version_oss past the root while alembic_version stays
parked at the align revision.
No-op revision demonstrating EE-only divergence: alembic_version_ee advances
in EE databases while the shared and parked chains are untouched, and OSS
never sees it.
align = a00000000000, shared chain root/proof = o00000000001/2, EE chain
root/proof = e00000000001/2; file names and in-file revision/down_revision
ids match the agreed scheme.
Mirror the core chain split for tracing (its own database): park the legacy
tracing chain at park00000000, then a shared post-alignment chain tracing_oss
(alembic_version_tracing_oss, root oss000000000 + proof) and an EE-only chain
tracing_ee (alembic_version_tracing_ee, root ee0000000000 + proof). Wire both
runners (oss: +migrate_tracing_oss; ee: +migrate_tracing_oss +migrate_tracing_ee).

Same id scheme as core; tracing has its own version tables so ids do not collide.
tracing_ee is root+proof only — no EE-only tracing tables to adopt on a switch.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The split tracing chains tracked their versions in alembic_version_tracing_oss
and alembic_version_tracing_ee; the tracing database has its own version tables,
so the _tracing infix is redundant. Rename to alembic_version_oss /
alembic_version_ee to match the core chains, updating env VERSION_TABLE, the
runner utils log/error strings, and the chain root/proof/park docstrings in both
editions.
The revision regex only matched [a-f0-9], so the split-chain ids that start
with a non-hex letter (oss chain 'o00...') parsed as zero revisions and
find_head reported an empty tree / 'Heads: []'. The ee chain ('e00...') and
legacy hex ids happened to pass. Widen the capture to [^"] like the
down_revision pattern already does, so any alembic id resolves.
@junaway junaway force-pushed the feat/migration-chain-split branch from 5bd61fd to 5c39511 Compare June 14, 2026 15:44
junaway pushed a commit that referenced this pull request Jun 14, 2026
…ranch

The interim-to-final id rename of the chain-split files belongs on #4680, not
here. Rename those six files back to interim ids so #4680 can own the rename;
the adoption file keeps its final id and relinks to the interim ee proof.
junaway pushed a commit that referenced this pull request Jun 14, 2026
#4680 renames the chain-split migrations to the final ids; drop this branch's
interim revert so the stack stays at the final scheme end to end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backend Feature Request New feature or request size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant