ESC
> launch.rentals beta
Home › Docs ›Operations › Database & Migrations

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

  1. Edit the schema file.
  2. Run npm run db:generate to create a new SQL file in drizzle/.
  3. 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.