mirror of
https://github.com/ent/ent.git
synced 2026-04-27 21:20:51 +03:00
dialect/sql/schema: allow only table creation modification in automatic schema planning (#3660)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user