Fix seed.ts to drop all tables dynamically, add db:reset script - #64
Open
webfliccy wants to merge 1 commit into
Open
Fix seed.ts to drop all tables dynamically, add db:reset script#64webfliccy wants to merge 1 commit into
webfliccy wants to merge 1 commit into
Conversation
seed.ts dropped a hardcoded list of tables before calling migrate(), which left stale tables (e.g. an old course_reviews table) behind when migration history was regenerated, causing migrate() to leave the schema half-applied (no such table: modules). Now seed.ts queries sqlite_master and drops every table before migrating, guaranteeing a clean slate regardless of schema drift. Also adds pnpm db:reset as a one-command fix for a stale local DB. Fixes ai-hero-dev#63
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
Fixes #63
seed.tsnow queriessqlite_masterfor every existing table and drops them dynamically (instead of a hardcoded list), so leftover/renamed tables (e.g. an oldcourse_reviewstable) no longer leave the DB half-migrated.db:resetscript (rm -f data.db data.db-shm data.db-wal && pnpm db:seed) so a stale local DB can be fixed with one command instead of manual file deletion.Test plan
pnpm db:reseton a DB with schema drift (e.g. an extra/old table not in the current drop list) and confirmmigrate()completes cleanlypnpm db:seedon a fresh DB and confirm seeding still succeeds as before