Forge Migrations & Schema
Overview
Use schema primitives to define models and manage database changes with the migration system.
When to Use
- •The task mentions schema primitives or migration files.
- •You need to generate, apply, roll back, or validate migrations.
- •The user asks about migration status, linting, or fake migrations.
Quick Start
- •Update models and schema definitions.
- •Generate migrations with
forge makemigrations <name> --auto. - •Apply with
forge migrateand check status withforge migrate status.
Common Tasks
- •Preview migration plans with
forge migrate show. - •Lint migrations with
forge migrate lintand--verbosewhen debugging. - •Roll back with
forge migrate down 1or apply to a version withforge migrate up <n>. - •Use
forge migrate fakeor--fake-initialfor existing databases.
Gotchas
- •Migration files must live under
migrations/and follow*_*.up.sqland*_*.down.sqlnaming. - •Dependency auto-detection relies on relations and references in model definitions.
- •Always verify pending migrations before applying in production.