Repository navigation
chore(db): prune old drizzle migration snapshots - #3217
Merged
Merged
Conversation
drizzle-kit diffs the schema against the newest snapshot and runtime migrations read only migration.sql, so older snapshot.json files are dead weight. Keep the newest 10 and prune the rest after db:generate. Also drop the db:check script, which pointed at a missing check.ts. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 42 minutes. View limit details
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. |
This branch had an error being deployed
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
packages/db/.drizzle/migrationsheld one full-schemasnapshot.jsonper migration (48 files, about 213k lines). Only the recent ones are used:drizzle-kit generatediffs the schema against the newest snapshot.drizzle-kit migrateand the runtimemigrate()readmigration.sqlonly.This PR, following lobehub/lobehub#21907:
migration.sqlis untouched. The folder goes from 6.6M to 1.7M.packages/db/prune-snapshots.tsand runs it aspostdb:generate, so each new migration commits its own pruning.packages/db/AGENTS.md.db:checkscript, which pointed at acheck.tsthat does not exist.Notes
postdb:generaterather thandrizzle-kit generate && …, sopnpm db:generate --name foostill passes--nameto drizzle-kit.checkbefore every generate and needs the snapshot two branches forked at. Without it,checkdiffs both branches against an empty schema and exits 1 with a false conflict (reproduced on a copy of the folder). Ten is enough as long as no unmerged branch forked more than ten migrations ago.drizzle-kit generatedirectly skips the pruning; the nextdb:generatecatches up.Verification
pnpm run db:generatereportsNo schema changes, nothing to migrateanddrizzle-kit checkreportsEverything's fine.pnpm --filter @chia/db test: 59 tests pass, including 3 new ones forpruneSnapshots.tsc --noEmitandoxlinton the new files are clean.drizzle-kit migrateagainst a database. The migrator source readsmigration.sqlonly, and those files are unchanged.🤖 Generated with Claude Code