fix: squash drizzle migrations into one idempotent baseline (#713) - #837
Merged
Conversation
The 19 migrations in drizzle/*.sql had drifted out of sync with the 8
snapshots under drizzle/meta/ (all with empty `tables: {}`), leaving the
snapshot chain malformed and `npm run db:generate` broken.
With no external installs yet (only bardo, fully upgraded), re-syncing the
metadata carefully isn't worth it — so this is a clean slate: delete every
migration and snapshot and regenerate a single baseline from schema.ts.
drizzle-kit's SQLite dialect emits bare `CREATE TABLE`/`CREATE INDEX`, which
would fail on an install already at this schema. Every statement is hand-edited
to `IF NOT EXISTS` so bardo's populated DB runs the baseline as a no-op (drizzle
still applies it, since its `when` postdates bardo's last migration) while a
fresh DB builds the full schema. Verified both paths plus data survival.
Removes test/db-migrations.test.ts: it exercised in-place data migration
*through* the intermediate rename/retype steps (0015/0016/0017), slicing the
journal at those exact tags. The squash collapses those steps into the baseline,
so that scenario — a live DB upgrading across the renames, which bardo already
completed — no longer exists in the chain.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Explains why hand-written migrations break the Drizzle snapshot chain and documents the idempotent baseline pattern. Co-Authored-By: Claude <noreply@anthropic.com>
Ensures Claude Code coders see the rule without needing to read drizzle/README.md first. Co-Authored-By: Claude <noreply@anthropic.com>
psamiton
approved these changes
Jul 24, 2026
hekataion
enabled auto-merge (squash)
July 24, 2026 15:16
This was referenced Jul 24, 2026
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.
Summary
The 19 migrations in
drizzle/*.sqlhad drifted out of sync with the 8 snapshots underdrizzle/meta/(all with emptytables: {}), leaving the snapshot chain malformed andnpm run db:generatebroken.With no external installs yet (only bardo, fully upgraded), re-syncing the metadata carefully is not worth it — this is a clean slate:
schema.tsIF NOT EXISTSso existing installs run it as a no-opRemoves
test/db-migrations.test.tswhich tested in-place data migration through intermediate rename steps (0015/0016/0017) that no longer exist in the squashed chain.Verification
npm run db:generateruns cleandb:migrateIF NOT EXISTS)Fixes #713
🤖 Generated with Claude Code