Skip to content

Commit

Permalink
Make data-packing toggle-able (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
bplunkett-stripe authored Mar 21, 2024
1 parent 0492c3e commit 20140e8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cmd/pg-schema-diff/plan_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ type (

schemaFlags schemaFlags

dataPackNewTables bool

statementTimeoutModifiers []string
lockTimeoutModifiers []string
insertStatements []string
Expand Down Expand Up @@ -121,6 +123,8 @@ func createPlanFlags(cmd *cobra.Command) *planFlags {

schemaFlagsVar(cmd, &flags.schemaFlags)

cmd.Flags().BoolVar(&flags.dataPackNewTables, "data-pack-new-tables", true, "If set, will data pack new tables in the plan to minimize table size (re-arranges columns).")

timeoutModifierFlagVar(cmd, &flags.statementTimeoutModifiers, "statement", "t")
timeoutModifierFlagVar(cmd, &flags.lockTimeoutModifiers, "lock", "l")
cmd.Flags().StringArrayVarP(
Expand Down Expand Up @@ -170,6 +174,11 @@ func parsePlanConfig(p planFlags) (planConfig, error) {
return planConfig{}, err
}

opts := parseSchemaConfig(p.schemaFlags)
if p.dataPackNewTables {
opts = append(opts, diff.WithDataPackNewTables())
}

var statementTimeoutModifiers []timeoutModifier
for _, s := range p.statementTimeoutModifiers {
stm, err := parseTimeoutModifier(s)
Expand Down Expand Up @@ -199,7 +208,7 @@ func parsePlanConfig(p planFlags) (planConfig, error) {

return planConfig{
schemaSourceFactory: schemaSourceFactory,
opts: parseSchemaConfig(p.schemaFlags),
opts: opts,
statementTimeoutModifiers: statementTimeoutModifiers,
lockTimeoutModifiers: lockTimeoutModifiers,
insertStatements: insertStatements,
Expand Down Expand Up @@ -367,7 +376,6 @@ func generatePlan(ctx context.Context, logger log.Logger, connConfig *pgx.ConnCo
append(
planConfig.opts,
diff.WithTempDbFactory(tempDbFactory),
diff.WithDataPackNewTables(),
)...,
)
if err != nil {
Expand Down

0 comments on commit 20140e8

Please sign in to comment.