mirror of
https://github.com/ent/ent.git
synced 2026-05-22 09:31:45 +03:00
dialect/sql/schema: skip destructive table changes (#3253)
This will be fixed also in Atlas, but having this extra safety here feels safer
This commit is contained in:
@@ -789,7 +789,17 @@ func (a *Atlas) diff(ctx context.Context, name string, current, desired *schema.
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
plan, err := a.atDriver.PlanChanges(ctx, name, changes, opts...)
|
||||
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 {
|
||||
filtered = append(filtered, c)
|
||||
}
|
||||
}
|
||||
plan, err := a.atDriver.PlanChanges(ctx, name, filtered, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user