mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
dialect/sql/schema: add method to create a named versioned migration … (#2385)
* dialect/sql/schema: add method to create a named versioned migration file * doc/md: documentation for named versioned migrations * entc/gen/template/dialect/sql/feature: add NamedDiff method to create named versioned migration files * all: go generate * doc/md: apply CR
This commit is contained in:
@@ -82,6 +82,8 @@ func main() {
|
||||
}
|
||||
// Write migration diff.
|
||||
err = client.Schema.Diff(ctx, schema.WithDir(dir))
|
||||
// You can use the following method to give the migration files a name.
|
||||
// err = client.Schema.NamedDiff(ctx, "migration_name", schema.WithDir(dir))
|
||||
if err != nil {
|
||||
log.Fatalf("failed creating schema resources: %v", err)
|
||||
}
|
||||
@@ -137,6 +139,10 @@ func main() {
|
||||
if err := m.Diff(context.Background(), tbls...); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
// You can use the following method to give the migration files a name.
|
||||
// if err := m.NamedDiff(context.Background(), "migration_name", tbls...); err != nil {
|
||||
// log.Fatalln(err)
|
||||
// }
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user