fix: 忽略特定SQL执行错误重复字段、索引和未知字段错误
This commit is contained in:
@@ -97,13 +97,19 @@ func processSQLFile(db *gorm.DB, filePath string) {
|
||||
// log.Printf("Exec SQL: %s\n", line)
|
||||
// log.Println(err.Error())
|
||||
if strings.Contains(errorStr, "duplicate column") {
|
||||
// 忽略重复字段错误 Error 1060 (42S21): Duplicate column name 'field_name'
|
||||
// 忽略重复字段错误
|
||||
// Error 1060 (42S21): Duplicate column name 'field_name'
|
||||
// SQL logic error: duplicate column name: title (1)
|
||||
} else if strings.Contains(errorStr, "duplicate key") {
|
||||
// 忽略重复索引错误 Error 1061 (42000): Duplicate key name 'key_name'
|
||||
// 忽略重复索引错误
|
||||
// Error 1061 (42000): Duplicate key name 'key_name'
|
||||
} else if strings.Contains(errorStr, "unknown column") {
|
||||
// 忽略未知字段错误 Error 1054 (42S22): Unknown column 'field_name' in 'table'
|
||||
} else if strings.Contains(errorStr, "check that it exists") {
|
||||
// 忽略删除字段错误 Error 1091 (42000): Can't DROP COLUMN `field_name`; check that it exists
|
||||
// 忽略未知字段错误
|
||||
// Error 1054 (42S22): Unknown column 'field_name' in 'table'
|
||||
} else if strings.Contains(errorStr, "can't drop") {
|
||||
// 忽略删除字段或索引错误
|
||||
// Error 1091 (42000): Can't DROP COLUMN `field_name`; check that it exists
|
||||
// Error 1091 (42000): Can't DROP 'idx_ne_type_id'; check that column/key exists
|
||||
} else {
|
||||
// 其他错误终止程序
|
||||
log.Fatalln(errorStr)
|
||||
|
||||
Reference in New Issue
Block a user