From 6b8ce612ad5b67ee55d0ebdfc42b19f42ef778cf Mon Sep 17 00:00:00 2001 From: Codex Date: Thu, 24 Sep 2026 05:35:53 +1200 Subject: [PATCH] Initialize native mode schema synchronously before reading it --- ale/azerothai_lifecycle.lua | 5 +++-- tests/lifecycle-lua.test.py | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ale/azerothai_lifecycle.lua b/ale/azerothai_lifecycle.lua index eb9962a..b14dcfa 100644 --- a/ale/azerothai_lifecycle.lua +++ b/ale/azerothai_lifecycle.lua @@ -2,8 +2,9 @@ -- from its factory-created, unused starting-level reserve; identities are never reset. -- Install only after deploy/playable/install-lifecycle.py has seeded the registry. -- The persisted mode is synchronized from dashboard settings by operations-agent. -AuthDBExecute("CREATE TABLE IF NOT EXISTS azerothai_realm_rules (id TINYINT PRIMARY KEY,hardcore TINYINT NOT NULL)") -AuthDBExecute("INSERT IGNORE INTO azerothai_realm_rules VALUES (1,1)") +-- Schema setup must finish before the first synchronous mode read. +AuthDBQuery("CREATE TABLE IF NOT EXISTS azerothai_realm_rules (id TINYINT PRIMARY KEY,hardcore TINYINT NOT NULL)") +AuthDBQuery("INSERT IGNORE INTO azerothai_realm_rules VALUES (1,1)") function AzerothAIHardcoreEnabled() local q=AuthDBQuery("SELECT hardcore FROM azerothai_realm_rules WHERE id=1") return not q or q:GetUInt32(0)~=0 diff --git a/tests/lifecycle-lua.test.py b/tests/lifecycle-lua.test.py index 7071a7c..d2aac21 100644 --- a/tests/lifecycle-lua.test.py +++ b/tests/lifecycle-lua.test.py @@ -20,7 +20,9 @@ function player(guid,name,account,level,dead) players[name]=p; return p end function AuthDBQuery(sql) - if string.find(sql,"azerothai_realm_rules",1,true) then return {GetUInt32=function()return mode or 1 end} end + if string.find(sql,"CREATE TABLE IF NOT EXISTS azerothai_realm_rules",1,true) then rulesReady=true;return nil end + if string.find(sql,"INSERT IGNORE INTO azerothai_realm_rules",1,true) then assert(rulesReady);return nil end + if string.find(sql,"SELECT hardcore FROM azerothai_realm_rules",1,true) then assert(rulesReady,'Schema must exist before synchronous mode reads');return {GetUInt32=function()return mode or 1 end} end if string.find(sql,'SELECT id FROM account',1,true) then if string.find(sql,'id=99 ',1,true) then return nil end return {GetUInt32=function() return 2 end}