Fix startup warnings: use psycopg2.sql.Identifier for ALTER TABLE OWNER (fixes single-quote syntax error), remove player_state indexes (it's a view, not a table)

This commit is contained in:
Reditus committed 2026-05-21 13:41:04 +01:00
1 parent 3e1386e6bd
commit 2d8728edc8
3 files changed
+8 -8

No files matched your search

+5 -3
View File
@@ -177,9 +177,11 @@ class DatabaseService:
)
""")
if self.db_owner:
cur.execute("ALTER TABLE IF EXISTS dune.player_ips OWNER TO %s", (self.db_owner,))
cur.execute("ALTER TABLE IF EXISTS dune.bans OWNER TO %s", (self.db_owner,))
cur.execute("ALTER TABLE IF EXISTS dune.player_actions OWNER TO %s", (self.db_owner,))
from psycopg2 import sql
owner_ident = sql.Identifier(self.db_owner).as_string(conn)
cur.execute(f"ALTER TABLE IF EXISTS dune.player_ips OWNER TO {owner_ident}")
cur.execute(f"ALTER TABLE IF EXISTS dune.bans OWNER TO {owner_ident}")
cur.execute(f"ALTER TABLE IF EXISTS dune.player_actions OWNER TO {owner_ident}")
conn.commit()
logger.info("Dashboard tables ensured (player_ips, bans, player_actions)")
except Exception as e: