Migration workflow
Follow these steps to go from a new project to applied migrations. For schema syntax see DSL syntax; for command details see CLI commands.
Initialize
Run once to create the project layout and config.
schema-forge initThis creates:
schemaforge/schema.sf,schemaforge/config.json,schemaforge/state.json, andsupabase/migrations/(or your configured output dir).Edit schema
Edit
schemaforge/schema.sfto define or change tables and columns. Use the DSL syntax reference.Preview (optional)
See what SQL would be generated without writing files.
schema-forge diffIf the schema matches the tracked state, you’ll see no changes. Otherwise the diff shows the migration SQL.
Generate migration
Write a timestamped migration file and update the state file.
schema-forge generate --name "add user avatar"A new SQL file appears in your migrations directory. For destructive changes, Schema Forge may prompt for confirmation (or use
--safe/--force; see CLI commands).Apply migration
Run the generated SQL against your database using your preferred tool (e.g.
psql, Supabase dashboard, or a migration runner). Schema Forge does not apply migrations itself.Repeat
Edit
schema.sf→ rundiff(optional) →generate→ apply the new migration. Commit schema files and migrations to version control.
Default value changes
Schema Forge tracks default changes on existing columns. Adding, removing, or changing default <expr> in the DSL produces ALTER TABLE ... ALTER COLUMN ... SET DEFAULT or DROP DEFAULT in the generated migration.
Migration preview in CI
You can run schema-forge diff in CI and post the migration SQL as a PR comment. See the schema-forge-action repo for the GitHub Action and usage.