Add db_owner setting to reassign table ownership to game server DB user for backup compatibility

This commit is contained in:
Reditus committed 2026-05-21 06:37:31 +01:00
1 parent 5f26621744
commit 6fe4384d91
5 files changed
+18 -4

No files matched your search

+6 -1
View File
@@ -10,10 +10,11 @@ logger = logging.getLogger(__name__)
class DatabaseService:
def __init__(self, db_config, min_conn=2, max_conn=10):
def __init__(self, db_config, min_conn=2, max_conn=10, db_owner='dune'):
self.db_config = db_config
self.min_conn = min_conn
self.max_conn = max_conn
self.db_owner = db_owner
self.pool = None
def init_pool(self):
@@ -175,6 +176,10 @@ class DatabaseService:
created_at TIMESTAMP NOT NULL DEFAULT NOW()
)
""")
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,))
conn.commit()
logger.info("Dashboard tables ensured (player_ips, bans, player_actions)")
except Exception as e: