fix: schema_compat 跳过不存在的表,避免 columnPatch 对缺失表 panic
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m33s
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m33s
Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
parent
772c12f821
commit
b3c721ee58
@ -15,9 +15,9 @@ Logger: # 日志配置
|
|||||||
Level: debug # 日志级别: debug, info, warn, error, panic, fatal
|
Level: debug # 日志级别: debug, info, warn, error, panic, fatal
|
||||||
|
|
||||||
MySQL:
|
MySQL:
|
||||||
Addr: 127.0.0.1:3306 # host 网络模式; bridge 模式改为 mysql:3306
|
Addr: 154.12.35.103:3306 # host 网络模式; bridge 模式改为 mysql:3306
|
||||||
Username: root # MySQL用户名
|
Username: root # MySQL用户名
|
||||||
Password: CHANGE_ME_MYSQL_PASSWORD # MySQL密码,与 .env MYSQL_ROOT_PASSWORD 一致
|
Password: jpcV41ppanel # MySQL密码,与 .env MYSQL_ROOT_PASSWORD 一致
|
||||||
Dbname: ppanel # MySQL数据库名
|
Dbname: ppanel # MySQL数据库名
|
||||||
Config: charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai
|
Config: charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai
|
||||||
MaxIdleConns: 10
|
MaxIdleConns: 10
|
||||||
|
|||||||
@ -138,6 +138,14 @@ func EnsureSchemaCompatibility(ctx *svc.ServiceContext) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, patch := range columnPatches {
|
for _, patch := range columnPatches {
|
||||||
|
tblExists, err := tableExists(ctx.DB, patch.table)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrapf(err, "check table %s failed", patch.table)
|
||||||
|
}
|
||||||
|
if !tblExists {
|
||||||
|
logger.Infof("[SchemaCompat] skipping column patch %s.%s: table does not exist", patch.table, patch.column)
|
||||||
|
continue
|
||||||
|
}
|
||||||
exists, err := columnExists(ctx.DB, patch.table, patch.column)
|
exists, err := columnExists(ctx.DB, patch.table, patch.column)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "check column %s.%s failed", patch.table, patch.column)
|
return errors.Wrapf(err, "check column %s.%s failed", patch.table, patch.column)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user