SQLStore: Add deprecation comments for breaking migrations (#49740)

* Migrator: Extend support to rename columns

* SQLStore: Add deprecation comments for breaking migrations
This commit is contained in:
Joan López de la Franca Beltran
2022-06-03 17:42:08 +02:00
committed by GitHub
parent 36c3398c6d
commit 5f1305d280
5 changed files with 35 additions and 21 deletions
@@ -118,18 +118,12 @@ func (db *MySQLDialect) ColumnCheckSQL(tableName, columnName string) (string, []
return sql, args
}
func (db *MySQLDialect) RenameColumn(table Table, oldName, newName string) string {
var colType string
for _, col := range table.Columns {
if col.Name == oldName {
colType = db.SQLType(col)
break
}
}
func (db *MySQLDialect) RenameColumn(table Table, column *Column, newName string) string {
quote := db.dialect.Quote
return fmt.Sprintf("ALTER TABLE %s CHANGE %s %s %s", quote(table.Name), quote(oldName), quote(newName), colType)
return fmt.Sprintf(
"ALTER TABLE %s CHANGE %s %s %s",
quote(table.Name), quote(column.Name), quote(newName), db.SQLType(column),
)
}
func (db *MySQLDialect) CleanDB() error {