Skip to content

Commit c4737ba

Browse files
committed
refactor the drop type method
1 parent c5f8b8e commit c4737ba

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

oracle/migrator.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,16 @@ func (m Migrator) CreateType(typeName, typeKind, typeof string) error {
496496

497497
// DropType drops an Oracle user-defined type
498498
func (m Migrator) DropType(typeName string) error {
499-
sql := fmt.Sprintf(`DROP TYPE "%s" FORCE`, strings.ToLower(typeName))
499+
sql := fmt.Sprintf(`
500+
BEGIN
501+
EXECUTE IMMEDIATE 'DROP TYPE "%s" FORCE';
502+
EXCEPTION
503+
WHEN OTHERS THEN
504+
IF SQLCODE != -4043 THEN
505+
RAISE;
506+
END IF;
507+
END;`, strings.ToLower(typeName))
508+
500509
return m.DB.Exec(sql).Error
501510
}
502511

0 commit comments

Comments
 (0)