fix(db): seed __drizzle_migrations from legacy migration table on EFS boot - #74
Merged
Merged
Conversation
…st boot Drizzle beta.19 tracked applied migrations in a `migration` table (id TEXT PRIMARY KEY). rc.2 switched to `__drizzle_migrations` (name column). On the EFS production database the old table exists but the new one does not, so rc.2 sees all migrations as unapplied and re-runs them — crashing on `ALTER TABLE session ADD metadata text` because the column already exists. Before handing off to applyMigrations, check for the legacy table and seed `__drizzle_migrations` with any migration folder names that appear in both the journal and the old table. rc.2 then skips already-applied work and the server boots normally. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 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 |
hoj-unleash
self-requested a review
August 19, 2026 00:22
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.
Root cause
The ECS container was crashing immediately after deployment, causing
aws ecs wait services-stableto time out after 10 minutes.drizzle-orm beta.19 (previously used) tracked applied migrations in a
migrationtable:drizzle-orm 1.0.0-rc.2 (merged in PR #72/#73) switched to
__drizzle_migrations:The EFS production database has the legacy
migrationtable but no__drizzle_migrations. When rc.2 starts, it sees an empty__drizzle_migrations, treats all migrations as unapplied, and tries to re-run20260511173437_session-metadata— which crashes with:(The
ALTER TABLE session ADD metadata textwas already applied.)Fix
Before calling
applyMigrations(), detect the legacymigrationtable and seed__drizzle_migrationsfrom it. rc.2 then skips already-applied work and boots normally.Verification
__drizzle_migrations)bun run --cwd packages/opencode src/index.ts servestarts without errors:opencode server listening on http://0.0.0.0:4099Deploy
After merge, trigger the
deploy-collab.ymlworkflow to redeploy to ECS.