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
+10 -3
View File
@@ -36,8 +36,12 @@ type Dialect interface {
DropTable(tableName string) string
DropIndexSQL(tableName string, index *Index) string
// RenameTable is deprecated, its use cause breaking changes
// so, it should no longer be used. Kept for legacy reasons.
RenameTable(oldName string, newName string) string
RenameColumn(table Table, oldName, newName string) string
// RenameColumn is deprecated, its use cause breaking changes
// so, it should no longer be used. Kept for legacy reasons.
RenameColumn(table Table, column *Column, newName string) string
UpdateTableSQL(tableName string, columns []*Column) string
@@ -211,9 +215,12 @@ func (b *BaseDialect) RenameTable(oldName string, newName string) string {
return fmt.Sprintf("ALTER TABLE %s RENAME TO %s", quote(oldName), quote(newName))
}
func (b *BaseDialect) RenameColumn(table Table, oldName, newName string) string {
func (b *BaseDialect) RenameColumn(table Table, column *Column, newName string) string {
quote := b.dialect.Quote
return fmt.Sprintf("ALTER TABLE %s RENAME COLUMN %s TO %s", quote(table.Name), quote(oldName), quote(newName))
return fmt.Sprintf(
"ALTER TABLE %s RENAME COLUMN %s TO %s",
quote(table.Name), quote(column.Name), quote(newName),
)
}
func (b *BaseDialect) ColumnCheckSQL(tableName, columnName string) (string, []interface{}) {