From c24e12538f40c3ba10742f09f64e4351bd1f2ca6 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Fri, 23 May 2025 17:02:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BF=BD=E7=95=A5=E7=89=B9=E5=AE=9ASQL?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E9=94=99=E8=AF=AF=E9=87=8D=E5=A4=8D=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E3=80=81=E7=B4=A2=E5=BC=95=E5=92=8C=E6=9C=AA=E7=9F=A5?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/framework/database/db/expand.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/framework/database/db/expand.go b/src/framework/database/db/expand.go index 2be66e66..209c4eea 100644 --- a/src/framework/database/db/expand.go +++ b/src/framework/database/db/expand.go @@ -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)