1
0

Make sure all tables are properly pluralized

This commit is contained in:
kolaente
2021-03-28 20:17:35 +02:00
parent bc782e68ff
commit 73f2d4532d
29 changed files with 178 additions and 96 deletions

View File

@ -158,6 +158,29 @@ func modifyColumn(x *xorm.Engine, tableName, col, newDefinition string) error {
return nil
}
func renameTable(x *xorm.Engine, oldName, newName string) error {
switch config.DatabaseType.GetString() {
case "sqlite":
_, err := x.Exec("ALTER TABLE `" + oldName + "` RENAME TO `" + newName + "`")
if err != nil {
return err
}
case "mysql":
_, err := x.Exec("RENAME TABLE `" + oldName + "` TO `" + newName + "`")
if err != nil {
return err
}
case "postgres":
_, err := x.Exec("ALTER TABLE `" + oldName + "` RENAME TO `" + newName + "`")
if err != nil {
return err
}
default:
log.Fatal("Unknown db.")
}
return nil
}
func initSchema(tx *xorm.Engine) error {
schemeBeans := []interface{}{}
schemeBeans = append(schemeBeans, models.GetTables()...)