Database Commands
Database commands manage PostgreSQL schema migrations and data seeding. FORGE generates numbered SQL migration files and Rust-compatible seeders that run in deterministic order.
forge migrate:run
Run all pending migrations against the connected database.
Usage
forge migrate:run [OPTIONS]Options
| Option | Type | Default | Description |
|---|---|---|---|
--verbose | flag | false | Print each SQL statement as it executes. |
Example
forge migrate:run --verboseRunning pending migrations...
[1/3] 00014_create_contents_table applied (12 ms)
[2/3] 00015_create_menus_table applied (8 ms)
[3/3] 00016_migrate_media_polymorphic applied (15 ms)
All migrations applied successfully.forge migrate:fresh
Drop every table in the database and re-run all migrations from scratch. Optionally seed the database afterward.
Usage
forge migrate:fresh [OPTIONS]Options
| Option | Type | Default | Description |
|---|---|---|---|
--seed | flag | false | Run seeders after migrations complete. |
DANGER
migrate:fresh destroys all data. It drops every table, including those not managed by FORGE. Never run this against a production database.
Example
forge migrate:fresh --seedforge migrate:status
Display a table showing which migrations have been applied and which are pending.
Usage
forge migrate:statusExample Output
┌────┬──────────────────────────────────────────┬──────────┬─────────────────────┐
│ # │ Migration │ Status │ Applied At │
├────┼──────────────────────────────────────────┼──────────┼─────────────────────┤
│ 1 │ 00001_create_users_table │ Applied │ 2025-04-10 08:12:03 │
│ 2 │ 00002_create_roles_table │ Applied │ 2025-04-10 08:12:03 │
│ 3 │ 00003_create_permissions_table │ Applied │ 2025-04-10 08:12:03 │
│ .. │ ... │ ... │ ... │
│ 14 │ 00014_create_contents_table │ Pending │ — │
│ 15 │ 00015_create_menus_table │ Pending │ — │
└────┴──────────────────────────────────────────┴──────────┴─────────────────────┘forge migrate:rollback
Reverse the most recent batch of migrations, or roll back a specific number of steps.
Usage
forge migrate:rollback [OPTIONS]Options
| Option | Type | Default | Description |
|---|---|---|---|
--step | number | 1 | Number of migration steps to reverse. |
WARNING
Rollback executes the down SQL for each migration in reverse order. Make sure your down migrations are tested before relying on this in staging or production.
Examples
# Roll back the last migration
forge migrate:rollback
# Roll back the last 3 migrations
forge migrate:rollback --step 3forge migrate:reset
Roll back every applied migration, leaving the database with only the _migrations tracking table.
Usage
forge migrate:resetDANGER
migrate:reset reverses all migrations. All data will be lost. This is equivalent to migrate:rollback --step <total>.
forge seed
Run database seeders to populate the database with initial or test data.
Usage
forge seed [OPTIONS]Options
| Option | Type | Default | Description |
|---|---|---|---|
--class | string | — | Run a specific seeder by name instead of all seeders. |
--refresh | flag | false | Truncate all seeded tables before re-running seeders. |
Examples
# Run all seeders
forge seed
# Run a specific seeder
forge seed --class permissions
# Truncate and re-seed everything
forge seed --refreshWARNING
The --refresh flag truncates tables in cascade order before re-seeding. Existing data in those tables will be deleted.
Common Workflows
Initial setup after cloning a project:
forge migrate:run
forge seedReset everything during development:
forge migrate:fresh --seedCheck what needs to run before deploying:
forge migrate:statusSee Also
- Generator Commands — create new migrations and seeders with
make:migrationandmake:seeder - Development Commands — start servers and run tests
- Deployment Commands — deploy with migrations in production