Skip to content

sql: gate potentially unsafe schema changes behind sql_safe_updates #51863

@ajwerner

Description

@ajwerner

Is your feature request related to a problem? Please describe.
There are some combinations of schema changes which can be hazardous and potentially cause data loss. Their are two classes of known problems to which this issue pertains. One, it can be problematic to drop columns which have constraints (see #47719). The second set of problems pertains to transactions which drop columns and perform other asynchronous schema changes which might fail. In those scenarios (#46541, #47712).

These situations are bad, but are not hard to avoid. Let's help guide our users to avoid them.

Describe the solution you'd like

I'd like the sql_safe_updates flag to prevent the two above problems. If you want to drop a column and you have sql_safe_updates enabled, then you need to drop its constraints first and you cannot drop it in the same transaction that adds columns with default or computed expressions or adds other constraints.

Describe alternatives you've considered
We should ultimately fix the underlying bugs but it's challenging.

Metadata

Metadata

Assignees

Labels

A-schema-changesC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions