mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 07:32:32 +01:00
fix: prevent startup panics on databases missing base tables
The catch-up migration now creates the servers table if missing, like sign_sessions. Startup cleanup queries in main.go use Exec instead of MustExec so missing tables log warnings rather than panicking.
This commit is contained in:
12
main.go
12
main.go
@@ -240,11 +240,17 @@ func main() {
|
||||
if len(ownedServerIDs) > 0 {
|
||||
idList := strings.Join(ownedServerIDs, ",")
|
||||
if config.DebugOptions.ProxyPort == 0 {
|
||||
_ = db.MustExec("DELETE FROM sign_sessions WHERE server_id IN (" + idList + ")")
|
||||
if _, err := db.Exec("DELETE FROM sign_sessions WHERE server_id IN (" + idList + ")"); err != nil {
|
||||
logger.Warn("Failed to clear stale sign sessions", zap.Error(err))
|
||||
}
|
||||
}
|
||||
if _, err := db.Exec("DELETE FROM servers WHERE server_id IN (" + idList + ")"); err != nil {
|
||||
logger.Warn("Failed to clear stale server entries", zap.Error(err))
|
||||
}
|
||||
_ = db.MustExec("DELETE FROM servers WHERE server_id IN (" + idList + ")")
|
||||
}
|
||||
_ = db.MustExec(`UPDATE guild_characters SET treasure_hunt=NULL`)
|
||||
if _, err := db.Exec(`UPDATE guild_characters SET treasure_hunt=NULL`); err != nil {
|
||||
logger.Warn("Failed to reset treasure hunts", zap.Error(err))
|
||||
}
|
||||
|
||||
// Clean the DB if the option is on.
|
||||
if config.DebugOptions.CleanDB {
|
||||
|
||||
Reference in New Issue
Block a user