fix que / add auto
This commit is contained in:
38
db.py
38
db.py
@@ -126,6 +126,7 @@ def init_db():
|
||||
cost_iron INTEGER NOT NULL DEFAULT 0,
|
||||
cost_battle_pts INTEGER NOT NULL DEFAULT 0,
|
||||
status TEXT NOT NULL DEFAULT 'pending', -- pending | success | failed
|
||||
source TEXT NOT NULL DEFAULT 'manual', -- 'manual' | 'auto'
|
||||
result_msg TEXT,
|
||||
fired_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
confirmed_at TEXT
|
||||
@@ -133,6 +134,43 @@ def init_db():
|
||||
''')
|
||||
c.execute('CREATE INDEX IF NOT EXISTS idx_culture_log_player_world ON culture_log(player_id, world_id)')
|
||||
|
||||
# Culture queue — dedicated queue for celebration commands (separate from commands table).
|
||||
# Max 1 pending/executing per player+world+celebration_type enforced at app level.
|
||||
# source: 'manual' (dashboard button) | 'auto' (server-side auto-fire from state push)
|
||||
c.execute('''
|
||||
CREATE TABLE IF NOT EXISTS culture_queue (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
player_id TEXT NOT NULL,
|
||||
world_id TEXT NOT NULL,
|
||||
town_id TEXT NOT NULL,
|
||||
town_name TEXT NOT NULL DEFAULT '',
|
||||
celebration_type TEXT NOT NULL, -- 'party' | 'triumph'
|
||||
status TEXT NOT NULL DEFAULT 'pending', -- pending | executing | done | failed
|
||||
source TEXT NOT NULL DEFAULT 'manual', -- 'manual' | 'auto'
|
||||
result_msg TEXT,
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
executed_at TEXT
|
||||
)
|
||||
''')
|
||||
c.execute('CREATE INDEX IF NOT EXISTS idx_culture_queue_player_world ON culture_queue(player_id, world_id, status)')
|
||||
|
||||
# Culture settings — per-town auto-mode toggle (party / triumph).
|
||||
# One row per player+world+town. Updated from Αγορά dashboard toggles.
|
||||
c.execute('''
|
||||
CREATE TABLE IF NOT EXISTS culture_settings (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
player_id TEXT NOT NULL,
|
||||
world_id TEXT NOT NULL,
|
||||
town_id TEXT NOT NULL,
|
||||
auto_party INTEGER NOT NULL DEFAULT 0,
|
||||
auto_triumph INTEGER NOT NULL DEFAULT 0,
|
||||
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
UNIQUE(player_id, world_id, town_id)
|
||||
)
|
||||
''')
|
||||
c.execute('CREATE INDEX IF NOT EXISTS idx_culture_settings_player_world ON culture_settings(player_id, world_id)')
|
||||
|
||||
|
||||
# Blueprints - assigns a blueprint to a specific town
|
||||
c.execute('''
|
||||
CREATE TABLE IF NOT EXISTS town_blueprints (
|
||||
|
||||
Reference in New Issue
Block a user