Repository navigation
Make the committed migrations produce the schema they claim - #250
Conversation
Someone installing Orbit and running db:migrate got a database missing twelve tables and nine columns, including mcp_grant, oauth_application and oauth_access_token, so the MCP server could not authenticate anyone. The baseline migration was generated before the doc tree, GitHub connect, saved view and MCP OAuth work and was never regenerated, while db:push built the right thing from the schema. Two documented paths, two different databases. Regenerate the baseline from the schema. A fresh db:migrate now answers db:check-drift with everything the schema declares, including the generated search_vector and the doc tree columns whose absence took production down. Nothing tracked the old journal, in production or in a dev database, so replacing the baseline strands no one. CI now builds a database the way someone installing this would, with db:migrate alone, and fails when it does not match the schema. That is the check that would have caught this.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
Next review available in: 1 minute You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
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. Comment |
The baseline creates gin_trgm_ops indexes, so drizzle-kit migrate alone aborted on a database without pg_trgm and left nothing behind: zero tables. push never hit this because it runs ensure-extensions first, and migrate did not. Give migrate the same step push has. The CI job added in this PR was creating the extension itself before calling migrate, so it proved migrations work on a database someone had already prepared, not on the fresh one the job claims to build. It now creates an empty database and runs migrate alone, which is what someone installing this actually does. Verified against a database carrying only plpgsql: reproduced the abort, then applied clean with no drift.
|
@coderabbitai review |
|
The problem
Someone installing Orbit and following the migration path got a broken database.
bun run db:migrateon a fresh database, before this change:Twelve tables and nine columns.
mcp_grant,oauth_applicationandoauth_access_tokenare the MCP OAuth tables, so on that database the MCP server could not authenticate anyone at all.The baseline was generated before the doc tree, GitHub connect, saved view and MCP OAuth work and was never regenerated.
db:pushbuilds the right thing because it reads the schema directly, so the two documented paths produced two different databases and only one of them worked.This is the same class of failure that took
/docsand/api/syncdown: schema that exists in code but not in a database. That one was a database nobody had applied the change to. This one ships in the repository.What changed
The baseline is regenerated from
packages/db/src/schema. A freshdb:migratenow answers:Including the pieces that are easy to lose:
doc.search_vectorasGENERATED ALWAYS AS (...) STOREDwith its GIN index,doc.sort_order,doc_collection.position, and all four of the MCP and doc access tables.Replacing the baseline strands nobody: no database tracks the old journal. Checked production and a dev database, and neither has a
__drizzle_migrationstable, because production is brought forward with the scripts inpackages/db/catchupand development usesdb:push.So it cannot rot again
A CI job builds a database the way someone installing this would, with
db:migrateand nothing else, then runsdb:check-driftagainst it. If a schema change lands without regenerating the baseline, that job fails.This is the check that would have caught the current state, and it is cheap: one Postgres service and two commands.
Verification
db:migrate+db:check-drift: clean, confirmed before and after so the failure is reproducibledb:push+db:check-drift: clean, unchanged by this PRpackages/dbtests: 150 passNot in this PR
The four
standup*tables are still in production and no longer in the schema, sodb:pushagainst production would drop them and the 31 rows they hold.db:check-driftreports them on every run. Removing them is a data decision, not a schema one.Greptile Summary
The PR regenerates the baseline migration from the current schema and adds CI validation for fresh migration-based installations.
pg_trgmthrough the database migration command before running Drizzle migrations.Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains; the migration command now installs
pg_trgmbefore applying the baseline, and the CI job exercises that same fresh-database path.Important Files Changed
Sequence Diagram
sequenceDiagram participant CI participant Installer as ensure-extensions.ts participant DB as Fresh PostgreSQL participant Drizzle participant Drift as check-drift.ts CI->>DB: Create orbit_from_migrations CI->>Installer: "Run @orbit/db migrate" Installer->>DB: CREATE EXTENSION IF NOT EXISTS pg_trgm Installer->>Drizzle: Continue after extension succeeds Drizzle->>DB: Apply regenerated baseline CI->>Drift: Run db:check-drift Drift->>DB: Read migrated tables and columns Drift-->>CI: Confirm migration matches schemaReviews (2): Last reviewed commit: "fix(db): let migrate install the extensi..." | Re-trigger Greptile