Core Commands¶
Apply and rollback migrations.
queen up¶
Apply pending migrations.
| Flag | Type | Default | Description |
|---|---|---|---|
--steps |
int | 0 | Apply only N migrations (0 = all) |
Examples¶
queen up # Apply all pending
queen up --steps 3 # Apply next 3
queen up --yes # Skip confirmation (CI/CD)
Output:
Behavior¶
- Each migration runs in a separate transaction.
- Lock prevents concurrent migrations.
- Checksums recorded after applying.
- If a migration fails, its transaction is rolled back and execution stops.
queen down¶
Rollback applied migrations.
| Flag | Type | Default | Description |
|---|---|---|---|
--steps |
int | 0 | Rollback N migrations (default: 1 if neither flag set) |
--to |
string | "" | Rollback to specific version (exclusive -- keeps the target) |
Cannot use both --steps and --to. If neither provided, rolls back 1 migration.
Examples¶
queen down # Rollback last migration
queen down --steps 2 # Rollback last 2
queen down --to 001 # Rollback to version 001 (keeps 001)
Output:
Behavior¶
- Migrations must have DownSQL or DownFunc defined.
- Destructive migrations show warnings before executing.
- Each rollback runs in its own transaction.
queen goto¶
Migrate to a specific version. Automatically determines direction.
Examples¶
If current version is 003, applies 004 and 005. If current version is 007, rolls back 007 and 006. If current version is 005, does nothing.
Accepts latest as a special version to apply all pending migrations.
Use Cases¶
- Hotfix rollback:
queen goto 009to revert to last known good version. - Staging sync:
queen goto 012to match production version.
queen reset¶
Rollback all applied migrations.
Examples¶
Output:
This will rollback ALL migrations:
010_add_feature
009_add_index
...
001_create_users
WARNING: This is a destructive operation
Continue? [y/N]
Requires double confirmation for destructive operations.
Use Cases¶
- Clean development database:
queen reset --yes && queen up - CI/CD testing:
queen up && go test ./... && queen reset --yes
Warning
All schema and data created by migrations is lost. Always backup production databases before reset.