feat: separate dashboard database + launcher repair/cleanup options

- Move dashboard tables (bans, player_ips, audit_log, chat_history,
  settings, player_actions) to a dedicated 'dashboard' database to
  prevent pg_dump conflicts during game updates
- Add DashboardDatabaseService (legacy + backend) with auto-migration
  from old dashboard schema on first startup
- Add launcher option 9: Repair Game Database (fixes schema ownership)
- Add launcher option 10: Clean up Old Dashboard Schema (drops old schema)
- Update PlayerService to fetch IPs from dashboard DB separately
- Update all routes and services to use dash_db for dashboard tables
- Add dashboard_database_name config option to settings.yaml.example
- Update README with new menu options
This commit is contained in:
Reditus committed 2026-05-27 01:02:39 +01:00
1 parent 15af849d2c
commit 0f173dc107
15 files changed
+837 -163

No files matched your search

+6 -6
View File
@@ -9,7 +9,7 @@ logger = logging.getLogger(__name__)
class ChatService:
def __init__(self, db_service, k8s_service, ssh_service, cache):
self.db = db_service
self.db = db_service # DashboardDatabaseService
self.k8s = k8s_service
self.ssh = ssh_service
self.cache = cache
@@ -20,7 +20,7 @@ class ChatService:
return True
try:
self.db.execute("""
CREATE TABLE IF NOT EXISTS dashboard.chat_history (
CREATE TABLE IF NOT EXISTS chat_history (
id SERIAL PRIMARY KEY,
timestamp TIMESTAMP DEFAULT NOW(),
channel VARCHAR(50),
@@ -33,7 +33,7 @@ class ChatService:
is_admin BOOLEAN DEFAULT FALSE
)
""")
self.db.execute("CREATE INDEX IF NOT EXISTS idx_chat_history_timestamp ON dashboard.chat_history (timestamp DESC)")
self.db.execute("CREATE INDEX IF NOT EXISTS idx_chat_history_timestamp ON chat_history (timestamp DESC)")
self.ensured_table = True
logger.info("Chat history table ready")
return True
@@ -46,7 +46,7 @@ class ChatService:
loc_y = location.get('Y', 0) if location else 0
loc_z = location.get('Z', 0) if location else 0
return self.db.execute("""
INSERT INTO dashboard.chat_history (channel, sender, message, target, location_x, location_y, location_z, is_admin)
INSERT INTO chat_history (channel, sender, message, target, location_x, location_y, location_z, is_admin)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s)
""", [channel, sender, message, target, loc_x, loc_y, loc_z, is_admin])
@@ -61,7 +61,7 @@ class ChatService:
cur = conn.cursor()
for msg in messages:
cur.execute("""
INSERT INTO dashboard.chat_history (channel, sender, message, target, location_x, location_y, location_z, is_admin)
INSERT INTO chat_history (channel, sender, message, target, location_x, location_y, location_z, is_admin)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s)
""", [
msg['channel'], msg['sender'], msg['message'],
@@ -87,7 +87,7 @@ class ChatService:
return self.db.query("""
SELECT id, timestamp, channel, sender, message, target,
location_x, location_y, location_z, is_admin
FROM dashboard.chat_history
FROM chat_history
ORDER BY timestamp DESC
LIMIT %s
""", [limit])