As a student of the AI coding for real engineers course this repo is used as a training example.
The course-work requires students to navigate commits on the dev branch.
I came across a situation where the current scripts don't correctly repopulate the database. This was causing errors when running the app locally.
Cause
Root cause: data.db was a leftover database whose __drizzle_migrations tracking didn't match the current drizzle/*.sql files (the _journal.json even has out-of-order timestamps for entries 3–5, suggesting the migration history was regenerated/squashed at some point). seed.ts drops a hardcoded list of tables before calling migrate(), but that list didn't include the old course_reviews table, so the drop+migrate left things half-applied.
My recommendation
Make seed.ts drop all existing tables dynamically (query sqlite_master and drop everything, not a fixed list) before running migrate() — that guarantees a truly empty DB every time, immune to schema drift from old/renamed tables. Pair it with a tiny db:reset script (rm -f data.db* && pnpm db:seed) so "stale DB" becomes a one-command fix instead of manual file deletion.
Tradeoff: dynamic drop is slightly less explicit/readable than the current list, but it's the part that actually failed here and is the kind of thing that'll bite again whenever migrations get regenerated.
As a student of the AI coding for real engineers course this repo is used as a training example.
The course-work requires students to navigate commits on the dev branch.
I came across a situation where the current scripts don't correctly repopulate the database. This was causing errors when running the app locally.
Cause
Root cause: data.db was a leftover database whose __drizzle_migrations tracking didn't match the current drizzle/*.sql files (the _journal.json even has out-of-order timestamps for entries 3–5, suggesting the migration history was regenerated/squashed at some point). seed.ts drops a hardcoded list of tables before calling migrate(), but that list didn't include the old course_reviews table, so the drop+migrate left things half-applied.
My recommendation
Make seed.ts drop all existing tables dynamically (query sqlite_master and drop everything, not a fixed list) before running migrate() — that guarantees a truly empty DB every time, immune to schema drift from old/renamed tables. Pair it with a tiny db:reset script (rm -f data.db* && pnpm db:seed) so "stale DB" becomes a one-command fix instead of manual file deletion.
Tradeoff: dynamic drop is slightly less explicit/readable than the current list, but it's the part that actually failed here and is the kind of thing that'll bite again whenever migrations get regenerated.