dialect/sql/schema: option to enable atlas sum file (#2470)

* dialect/sql/schema: option to enable atlas checksum file

* entc/integration/migrate: add integration tests for versioned migrations

* entc/integration/migrate: apply CR
This commit is contained in:
MasseElch
2022-04-13 21:36:57 +02:00
committed by GitHub
parent 89dc83887c
commit c1175719a2
28 changed files with 93 additions and 5521 deletions

View File

@@ -264,6 +264,13 @@ func WithFormatter(fmt migrate.Formatter) MigrateOption {
}
}
// WithSumFile instructs atlas to generate a migration directory integrity sum file as well.
func WithSumFile() MigrateOption {
return func(m *Migrate) {
m.atlas.genSum = true
}
}
type (
// atlasOptions describes the options for atlas.
atlasOptions struct {
@@ -273,6 +280,7 @@ type (
skip ChangeKind
dir migrate.Dir
fmt migrate.Formatter
genSum bool
}
// atBuilder must be implemented by the different drivers in

View File

@@ -186,7 +186,9 @@ func (m *Migrate) NamedDiff(ctx context.Context, name string, tables ...*Table)
}
opts := []migrate.PlannerOption{
migrate.WithFormatter(m.atlas.fmt),
migrate.DisableChecksum(),
}
if !m.atlas.genSum {
opts = append(opts, migrate.DisableChecksum())
}
return migrate.NewPlanner(nil, m.atlas.dir, opts...).WritePlan(plan)
}