fix: 忽略SQL执行中的未知字段和无此字段错误
This commit is contained in:
@@ -107,9 +107,10 @@ func processSQLFile(db *gorm.DB, filePath string) {
|
|||||||
// 忽略重复记录错误
|
// 忽略重复记录错误
|
||||||
// Error 1062 (23000): Duplicate entry 'value' for key 'key_name'
|
// Error 1062 (23000): Duplicate entry 'value' for key 'key_name'
|
||||||
log.Println(err.Error())
|
log.Println(err.Error())
|
||||||
} else if strings.Contains(errorStr, "unknown column") {
|
} else if strings.Contains(errorStr, "unknown column") || strings.Contains(errorStr, "no such column") {
|
||||||
// 忽略未知字段错误
|
// 忽略未知字段错误
|
||||||
// Error 1054 (42S22): Unknown column 'field_name' in 'table'
|
// Error 1054 (42S22): Unknown column 'field_name' in 'table'
|
||||||
|
// sql logic error: no such column: "field_name" (1)
|
||||||
} else if strings.Contains(errorStr, "can't drop") {
|
} 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 COLUMN `field_name`; check that it exists
|
||||||
|
|||||||
Reference in New Issue
Block a user