migration/

directory
v0.0.0-...-2f96202 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2023 License: Apache-2.0

README

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

1. Create a dev-database container if there is no one.

docker run --name migration --rm -p 3306:3306 -e MYSQL_ROOT_PASSWORD=pass -e MYSQL_DATABASE=test -d mysql

2. Generate a new versioned migration file:

go run -mod=mod ent/migrate/main.go <name>
Run migration linting
go run -mod=mod ariga.io/atlas/cmd/atlas@latest migrate lint \
  --dev-url="mysql://root:pass@localhost:3306/test" \
  --dir="file://ent/migrate/migrations" \
  --latest=1

Directories

Path Synopsis
ent
migrate/migratedata
Package migratedata holds the functions for generating data migration files.
Package migratedata holds the functions for generating data migration files.
pet

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL