Database & Migrations
Schema changes are SQL files in git and run on every build
The schema is defined with Drizzle in src/db/schema.ts and src/db/auth-schema.ts. SQL migrations
generated from it live in the drizzle/ folder and are committed.
Changing the schema
- Edit the schema file.
- Run
npm run db:generateto create a new SQL file indrizzle/. - Commit it together with the code that uses it.
The auth tables are regenerated from the Better Auth configuration with npm run auth:schema.
Applying
npm run db:migrate runs scripts/migrate.ts, which applies migrations that have not been applied
yet. Vercel runs it before every build, so a new database always ends up at the right version.
Inspecting data
npm run db:studio opens Drizzle Studio against the database in DATABASE_URL.