{"record":{"id":"0ee5cbdb2c2c4495","repo":"flipped-aurora/gin-vue-admin","slug":"error-0ee5cb","errorCode":null,"errorMessage":"删除失败!","messagePattern":"删除失败!","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/service/system/auto_code_package.go","lineNumber":113,"sourceCode":"\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfmt.Printf(\"[type:%s]注入成功!\\n\", key)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t})\n}\n\n// Delete 删除包记录\n// @author: [piexlmax](https://github.com/piexlmax)\n// @author: [SliverHorn](https://github.com/SliverHorn)\nfunc (s *autoCodePackage) Delete(ctx context.Context, info common.GetById) error {\n\terr := global.GVA_DB.WithContext(ctx).Delete(&model.SysAutoCodePackage{}, info.Uint()).Error\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"删除失败!\")\n\t}\n\treturn nil\n}\n\n// DeleteByNames\n// @author: [piexlmax](https://github.com/piexlmax)\n// @author: [SliverHorn](https://github.com/SliverHorn)\nfunc (s *autoCodePackage) DeleteByNames(ctx context.Context, names []string) error {\n\tif len(names) == 0 {\n\t\treturn nil\n\t}\n\terr := global.GVA_DB.WithContext(ctx).Where(\"package_name IN ?\", names).Delete(&model.SysAutoCodePackage{}).Error\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"删除失败!\")\n\t}\n\treturn nil\n}\n","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/service/system/auto_code_package.go#L95-L131","documentation":"The Delete method removes a SysAutoCodePackage row by ID; this error wraps any GORM error returned by that DELETE. It is a direct database failure (connection, constraint, or SQL error), not a 'not found' condition — GORM does not error when zero rows match.","triggerScenarios":"Calling autoCodePackage.Delete with a valid common.GetById while the database is unreachable, the sys_auto_code_packages table does not exist (migration not run), or a DB-level error occurs during the DELETE.","commonSituations":"Database migrated partially so the table is missing; MySQL/Postgres down or credentials wrong; connection pool exhausted; row locked by a long transaction causing timeout.","solutions":["Check the wrapped inner error for the underlying DB message (connection refused / table doesn't exist / deadlock)","Verify global.GVA_DB connectivity and credentials in config","Run migrations so model.SysAutoCodePackage (sys_auto_code_packages) exists: ensure AutoMigrate covers it","Retry if the error was a transient lock/timeout"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := global.GVA_DB.WithContext(ctx).Delete(&model.SysAutoCodePackage{}, info.Uint()).Error; err != nil {\n    var gormErr gorm.Error\n    if errors.As(err, &gormErr) {\n        log.Printf(\"db delete failed for id %d: %v\", info.ID, err)\n    }\n    return errors.Wrap(err, \"删除失败!\")\n}","preventionTips":["Run AutoMigrate for sys_auto_code_packages on startup","Add DB health checks before batch admin operations","Retry transient errors (deadlock, lock timeout) with backoff","Verify record existence first if you need 'not found' semantics (GORM delete of 0 rows returns nil)"],"tags":["database","gorm","mysql","delete"],"backgroundTag":"gorm-delete-failed","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}