example/migration: improve atlas migration example (#3092)

This commit is contained in:
Ariel Mashraki
2022-11-14 13:58:35 +02:00
committed by GitHub
parent 891fc8fecf
commit 8a8c72f377
18 changed files with 559 additions and 29 deletions

View File

@@ -12,19 +12,25 @@ Versioned migration files exists under `ent/migrate/migrations` and follows the
2\. Run `go generate ./ent`
### Generate new versioned migration
1\. Create a dev-database container if there is no one.
```shell
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
go run -mod=mod ent/migrate/main.go <name>
```
### Run linting
### Run migration linting
```bash
go run -mod=mod ariga.io/atlas/cmd/atlas@master migrate lint \
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" \
--dir-format="golang-migrate" \
--latest=1
```