Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions pkg/apitypes/apitypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -840,8 +840,18 @@ func (r *PlanResponse) HasErrors() bool {

// UnsafeChange represents a table change that is potentially destructive.
type UnsafeChange struct {
Table string
Reason string
Table string
Reason string
// Reasons is the change's findings, already separated. Renderers list and
// count these when they are set.
//
// It exists because Reason carries the engine-reported form, which joins a
// table's findings with "; ", so a renderer given only that has to split it
// back apart to list them. A reason written for one change is one sentence,
// and splitting it renders half of it as a finding of its own. Setting this
// is how a producer that knows its own findings says what they are; leaving
// it unset keeps the splitting, which is what an engine's plan needs.
Reasons []string `json:",omitempty"`
DDL string
ChangeType string
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/commands/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (cmd *ApplyCmd) Run(g *Globals) error {

// Show unsafe warning if --allow-unsafe was used
if cmd.AllowUnsafe {
templates.WriteUnsafeWarningAllowed(planResult.UnsafeChanges())
templates.WriteUnsafeWarningAllowed(planResult.UnsafeChanges(), templates.UnsafeConsentAllowFlag)
}

// Show options if any flags are set
Expand Down Expand Up @@ -396,7 +396,7 @@ func blockUnsafeApply(planResult *apitypes.PlanResponse, database, environment,

// Then show the unsafe changes warning
unsafeChanges := planResult.UnsafeChanges()
templates.WriteUnsafeChangesBlocked(unsafeChanges, database, environment, schemaDir)
templates.WriteUnsafeChangesBlocked(unsafeChanges, fmt.Sprintf("apply -s %s -e %s --allow-unsafe", schemaDir, environment))
return ErrSilent
}

Expand Down
Loading
Loading