dialect/sql/schema: allow planning with indentation (#3363)

This commit is contained in:
Ariel Mashraki
2023-03-04 10:06:53 +02:00
committed by GitHub
parent 9517200cb6
commit f16451eab8
7 changed files with 29 additions and 12 deletions

View File

@@ -33,11 +33,12 @@ type Atlas struct {
withFixture bool // deprecated: with fks rename fixture
sum bool // deprecated: sum file generation will be required
errNoPlan bool // no plan error enabled
universalID bool // global unique ids
dropColumns bool // drop deleted columns
dropIndexes bool // drop deleted indexes
withForeignKeys bool // with foreign keys
indent string // plan indentation
errNoPlan bool // no plan error enabled
universalID bool // global unique ids
dropColumns bool // drop deleted columns
dropIndexes bool // drop deleted indexes
withForeignKeys bool // with foreign keys
mode Mode
hooks []Hook // hooks to apply before creation
diffHooks []DiffHook // diff hooks to run when diffing current and desired
@@ -804,6 +805,11 @@ func (a *Atlas) diff(ctx context.Context, name string, current, desired *schema.
filtered = append(filtered, c)
}
}
if a.indent != "" {
opts = append(opts, func(opts *migrate.PlanOptions) {
opts.Indent = a.indent
})
}
plan, err := a.atDriver.PlanChanges(ctx, name, filtered, opts...)
if err != nil {
return nil, err