dialect/sql/schema: allow only table creation modification in automatic schema planning (#3660)

This commit is contained in:
Ariel Mashraki
2023-07-26 11:24:33 +03:00
committed by GitHub
parent 0b0cc90245
commit 91c7fcc685

View File

@@ -805,11 +805,12 @@ func (a *Atlas) diff(ctx context.Context, name string, current, desired *schema.
}
filtered := make([]schema.Change, 0, len(changes))
for _, c := range changes {
// Skip any table drops explicitly. The reason we may encounter this, even though specific tables are passed
// to Inspect, is if the MySQL system variable 'lower_case_table_names' is set to 1. In such a case, the given
// tables will be returned from inspection because MySQL compares case-insensitive, but they won't match when
// compare them in code.
if _, ok := c.(*schema.DropTable); !ok {
switch c.(type) {
// Select only table creation and modification. The reason we may encounter this, even though specific tables
// are passed to Inspect, is if the MySQL system variable 'lower_case_table_names' is set to 1. In such a case,
// the given tables will be returned from inspection because MySQL compares case-insensitive, but they won't
// match when compare them in code.
case *schema.AddTable, *schema.ModifyTable:
filtered = append(filtered, c)
}
}