fix: 忽略SQL执行中的未知字段和无此字段错误

This commit is contained in:
TsMask
2025-09-16 11:03:02 +08:00
parent 90bf6e092f
commit afe1ba484a

View File

@@ -107,9 +107,10 @@ func processSQLFile(db *gorm.DB, filePath string) {
// 忽略重复记录错误
// Error 1062 (23000): Duplicate entry 'value' for key 'key_name'
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'
// sql logic error: no such column: "field_name" (1)
} else if strings.Contains(errorStr, "can't drop") {
// 忽略删除字段或索引错误
// Error 1091 (42000): Can't DROP COLUMN `field_name`; check that it exists