refactor(documents): rename document owner fields

This commit is contained in:
2026-07-24 12:29:16 +08:00
parent ab8ba3c03f
commit f2d1fef2d6
16 changed files with 68 additions and 21 deletions

View File

@@ -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
}