Database Commands
Manage your database schema, migrations, seeders, and Drizzle Kit integration. All commands auto-detect your database dialect (SQLite, MySQL, PostgreSQL) from DATABASE_URL in .env.
npm run maker <command> [options]pnpm maker <command> [options]yarn maker <command> [options]bun maker <command> [options]Schema & Migrations
db:schema
Generate src/database/schema.ts by aggregating all model files from src/modules/*/database/models/. This is the single source of truth that Drizzle Kit reads.
Run this after creating or modifying any model file.
npm run maker db:schemapnpm maker db:schemayarn maker db:schemabun maker db:schemadb:generate
Generate Drizzle Kit migration SQL files under src/database/migrations/<dialect>/. Runs drizzle-kit generate behind the scenes.
- First migration is named
init - Subsequent migrations get timestamp-based names
npm run maker db:generatepnpm maker db:generateyarn maker db:generatebun maker db:generatedb:migrate
Generate migrations (if needed) then run them against the database. Equivalent to db:generate + db:migrate:run.
npm run maker db:migrate
npm run maker db:migrate -- --seedpnpm maker db:migrate
pnpm maker db:migrate --seedyarn maker db:migrate
yarn maker db:migrate --seedbun maker db:migrate
bun maker db:migrate --seeddb:migrate:run
Apply pending migrations only — does not generate new ones. Reads the meta/_journal.json to track which migrations have been applied.
npm run maker db:migrate:runpnpm maker db:migrate:runyarn maker db:migrate:runbun maker db:migrate:rundb:fresh
Drop all tables, regenerate schema, generate migrations, and run them. Useful during early development when the schema changes frequently.
Aliases: db:migrate:fresh
Dialect behavior:
| Dialect | Reset method |
|---|---|
| SQLite | Delete the .sqlite file and recreate |
| MySQL | DROP DATABASE + CREATE DATABASE |
| PostgreSQL | Terminate connections, DROP DATABASE + CREATE DATABASE |
npm run maker db:fresh
npm run maker db:fresh -- --seedpnpm maker db:fresh
pnpm maker db:fresh --seedyarn maker db:fresh
yarn maker db:fresh --seedbun maker db:fresh
bun maker db:fresh --seeddb:reset
Drop and recreate the database without running any migrations. Use db:fresh if you want migrations afterward.
Aliases: db:migrate:reset, db:wipe
npm run maker db:resetpnpm maker db:resetyarn maker db:resetbun maker db:resetdb:status
List all migration files with their dialect, showing which have been applied.
npm run maker db:statuspnpm maker db:statusyarn maker db:statusbun maker db:statusPush & Check
db:push
Push schema changes directly to the database without generating migration files. Uses drizzle-kit push. Useful for rapid prototyping.
Note:
pushdoes not create migration files. Usedb:generatefor production.
npm run maker db:pushpnpm maker db:pushyarn maker db:pushbun maker db:pushdb:check
Check for differences between your schema and the database. Uses drizzle-kit check. Reports any discrepancies without making changes.
npm run maker db:checkpnpm maker db:checkyarn maker db:checkbun maker db:checkSeeders
db:seed
Run all registered seeders by executing src/framework/database/seed.ts. Seeds are organized per-module under each module's database/seeders/ directory.
| Flag | Description |
|---|---|
--module <name> | Optional module name — run only that module's seeders |
npm run maker db:seed
npm run maker db:seed -- --module=postspnpm maker db:seed
pnpm maker db:seed --module=postsyarn maker db:seed
yarn maker db:seed --module=postsbun maker db:seed
bun maker db:seed --module=postsdb:module:seed <module>
Run seeders for a single module only.
npm run maker db:module:seed postspnpm maker db:module:seed postsyarn maker db:module:seed postsbun maker db:module:seed postsStudio
db:studio
Launch Drizzle Kit Studio — a web-based UI for browsing and editing your database. Opens at https://local.drizzle.studio.
npm run maker db:studio
npm run maker db:studio -- --quietpnpm maker db:studio
pnpm maker db:studio --quietyarn maker db:studio
yarn maker db:studio --quietbun maker db:studio
bun maker db:studio --quietShorthand
You can also use db <subcommand> instead of db:<subcommand>:
npm run maker db schema
npm run maker db migrate --seed
npm run maker db fresh --seed
npm run maker db seedUnsupported Commands
Drizzle Kit does not support Laravel-style rollback or refresh operations:
| Attempted | Why it fails | Use instead |
|---|---|---|
db:rollback | No down-migration concept | db:fresh --seed (local dev) or manual SQL |
db:refresh | No drop-and-re-run | db:fresh --seed |
db:migrate:rollback | Same as db:rollback | db:fresh --seed |
db:migrate:refresh | Same as db:refresh | db:fresh --seed |
Lifecycle
Schema files (*.ts)
│
▼
db:schema ──────────► src/database/schema.ts
│
▼
db:generate ─────────► Migration SQL files
│
▼
db:migrate:run ─────► Applied to database
│
▼
db:seed ────────────► Seed data inserted