We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1b4c47b commit dc97e56Copy full SHA for dc97e56
1 file changed
internal/mysql/schema.go
@@ -63,6 +63,18 @@ func (s *Schema) Add(ddl *sqlparser.DDL) error {
63
return fmt.Errorf("failed to parse table \"%s\" schema", name)
64
}
65
s.tables[name] = ddl.TableSpec.Columns
66
+ case "rename":
67
+ if len(ddl.FromTables) != 1 || len(ddl.ToTables) != 1 {
68
+ return fmt.Errorf("rename without one 'from' table and one 'to' table: %#v", ddl)
69
+ }
70
+ from := ddl.FromTables[0].Name.String()
71
+ to := ddl.ToTables[0].Name.String()
72
+ cols, ok := s.tables[from]
73
+ if !ok {
74
+ return fmt.Errorf("unknown existing table %q", from)
75
76
+ delete(s.tables, from)
77
+ s.tables[to] = cols
78
79
return nil
80
0 commit comments