refactor(documents): rename document owner fields
This commit is contained in:
@@ -44,5 +44,21 @@ func renameLegacyTables(database *gorm.DB) error {
|
||||
return fmt.Errorf("rename legacy table %s to %s: %w", table.legacy, table.current, err)
|
||||
}
|
||||
}
|
||||
if migrator.HasTable("sa_documents") {
|
||||
for _, column := range []struct {
|
||||
legacy string
|
||||
current string
|
||||
}{
|
||||
{legacy: "created_by", current: "owner_id"},
|
||||
{legacy: "created_by_identity", current: "owner_identity"},
|
||||
} {
|
||||
if !migrator.HasColumn("sa_documents", column.legacy) || migrator.HasColumn("sa_documents", column.current) {
|
||||
continue
|
||||
}
|
||||
if err := migrator.RenameColumn("sa_documents", column.legacy, column.current); err != nil {
|
||||
return fmt.Errorf("rename sa_documents column %s to %s: %w", column.legacy, column.current, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user