* Migrator: Extend support to rename columns
* SQLStore: Add deprecation comments for breaking migrations
(cherry picked from commit 5f1305d280)
Co-authored-by: Joan López de la Franca Beltran <5459617+joanlopez@users.noreply.github.com>
This commit is contained in:
co-authored by
Joan López de la Franca Beltran
parent
78d5e3e0dd
commit
fc4018048e
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user