This commit is contained in:
2024-05-10 10:27:21 +08:00
parent 90f807defc
commit 184a8722d8
9 changed files with 285 additions and 423 deletions

View File

@ -3,9 +3,8 @@ package oracle
import (
"database/sql"
"fmt"
"strings"
"gorm.io/gorm/schema"
"strings"
"gorm.io/gorm"
"gorm.io/gorm/clause"
@ -276,11 +275,11 @@ func (m Migrator) HasIndex(value interface{}, name string) bool {
// https://docs.oracle.com/database/121/SPATL/alter-index-rename.htm
func (m Migrator) RenameIndex(value interface{}, oldName, newName string) error {
// ALTER INDEX oldindex RENAME TO newindex;
panic("TODO")
return m.RunWithValue(value, func(stmt *gorm.Statement) error {
return m.DB.Exec(
"ALTER INDEX ? RENAME TO ?",
clause.Column{Name: oldName}, clause.Column{Name: newName},
"ALTER INDEX ?.? RENAME TO ?", // wat
clause.Table{Name: stmt.Table}, clause.Column{Name: oldName}, clause.Column{Name: newName},
).Error
})
}