Files
ent/examples/migration
Aagosh 326fe42d49 entc/gen: use FirstID instead of Count for Exist calls (#2896)
* Improve sqlexist template

* Address review comment and regenerate files

* Regenerate using go1.19

* Run go generate for examples dir

* Address review comment

* Update entc/gen/template/dialect/sql/query.tmpl

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
2022-09-04 10:04:57 +03:00
..

Versioned Migration Example

The full reference example for https://entgo.io/docs/versioned-migrations#create-a-migration-files-generator.

Migration directory

Versioned migration files exists under ent/migrate/migrations and follows the golang-migrate format.

Changes to the Ent schema

1. Change the ent/schema.

2. Run go generate ./ent

Generate new versioned migration

go run -mod=mod ent/migrate/main.go <name>

Run linting

go run -mod=mod ariga.io/atlas/cmd/atlas@master migrate lint \
  --dev-url="mysql://root:pass@localhost:3306/test" \
  --dir="file://ent/migrate/migrations" \
  --dir-format="golang-migrate" \
  --latest=1