Documentation
¶
Overview ¶
Command generate-migrations diffs the current Ent schemas under ent/schema/ against the latest applied state of migrations/<dialect>/ and emits a new goose-formatted SQL migration per dialect — all under a single shared timestamp prefix.
Atlas (ariga.io/atlas) is consumed as a Go library; no `atlas` CLI binary is required. For SQLite, the dev database is an in-memory sqlite3 instance. For PostgreSQL and MySQL/MariaDB, the dev URL is taken from the corresponding flag (or env var) and the database is destructively replayed against the embedded migration history before computing the diff — never point this at a production database.
Two modes:
go run ./cmd/generate-migrations --name=<descriptive_name>
schema-driven: diffs current Ent schemas against the latest
applied state and writes one .sql per dialect under
migrations/<dialect>/.
go run ./cmd/generate-migrations --sql-only --name=<descriptive_name>
SQL-only: writes empty goose stubs (-- +goose Up / -- +goose Down)
to each dialect directory. Used for data backfills and the
step-3 "constraint lock-in" of the four-step NOT NULL recipe.
`--name` is required in both modes and must be a descriptive snake_case identifier; placeholder names (auto, wip, tmp, empty) are rejected.