Add database migration for connected_at column

- Add ALTER TABLE to create connected_at column in existing databases
- Handle migration gracefully for databases created before schema update
parent 44bb31c4
...@@ -396,6 +396,16 @@ def init_db(conn) -> None: ...@@ -396,6 +396,16 @@ def init_db(conn) -> None:
) )
''') ''')
# Add connected_at column to cluster_clients if it doesn't exist
try:
if config['type'] == 'mysql':
cursor.execute('ALTER TABLE cluster_clients ADD COLUMN connected_at TIMESTAMP NULL')
else:
cursor.execute('ALTER TABLE cluster_clients ADD COLUMN connected_at TIMESTAMP')
except:
# Column might already exist, ignore error
pass
# Client driver preferences table (per worker) # Client driver preferences table (per worker)
if config['type'] == 'mysql': if config['type'] == 'mysql':
cursor.execute(''' cursor.execute('''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment