You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
diff/push: ignore CHECK constraint name changes unless --exact-match
In MySQL, check constraints have a schema-wide namespace. Since online schema
change tools use a "shadow table" matching the new requested table definition,
these tools manipulate the check constraint name in order to avoid a name
collision between the old table and the shadow table. (pt-osc does this
explicitly, similar to how it handles foreign key constraints; meanwhile
gh-ost and spirit do it automatically by virtue of using CREATE TABLE ... LIKE
to create the shadow table, which reverts check constraints to their server-
default naming scheme.)
However, as a side-effect of this CHECK constraint renaming, subsequent calls
to `skeema diff` or `skeema push` could previously result in spurious diffs to
return any named check constraints back to their original names from the *.sql
file definitions.
This commit changes Skeema's table diff logic to ignore check constraint name
changes by default, just like how foreign key constraint name changes are also
already ignored for the same reason. To override this behavior, the existing
option --exact-match can be used if needed.
Note that in MariaDB, check constraints have a per-table namespace instead of
a schema-wide namespace, and CREATE TABLE ... LIKE retains check constraint
names as-is, which means gh-ost won't rename check constraints. However,
gh-ost does not officially support MariaDB anyway. Meanwhile pt-osc still
renames check constraints on MariaDB even though it is not necessary. So the
changes in this commit are applied equally to both MySQL and MariaDB, since
some MariaDB users may be running pt-osc.
Copy file name to clipboardExpand all lines: internal/tengo/diff.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -77,7 +77,7 @@ type StatementModifiers struct {
77
77
LockClausestring// Include a LOCK=[value] clause in generated ALTER TABLE
78
78
AlgorithmClausestring// Include an ALGORITHM=[value] clause in generated ALTER TABLE
79
79
StrictIndexOrderbool// If true, maintain index order even in cases where there is no functional difference
80
-
StrictCheckOrderbool// If true, maintain check constraint order even though it never has a functional difference (only affects MariaDB)
80
+
StrictCheckConstraintsbool// If true, maintain check constraint definition even if differences are cosmetic (name change; relative order of check definitions in MariaDB)
81
81
StrictForeignKeyNamingbool// If true, maintain foreign key definition even if differences are cosmetic (name change, RESTRICT vs NO ACTION, etc)
82
82
StrictColumnDefinitionbool// If true, maintain column properties that are purely cosmetic (only affects MySQL 8)
83
83
LaxColumnOrderbool// If true, don't modify columns if they only differ by position
0 commit comments