0.4.2 - Early implementation of SLMs. WIP.
This commit is contained in:
46
scripts/migrate_dev_db.py
Normal file
46
scripts/migrate_dev_db.py
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Migrate DEV database to add SLM-specific columns
|
||||
"""
|
||||
|
||||
from sqlalchemy import create_engine, text
|
||||
|
||||
# DEV database
|
||||
DEV_DB_URL = "sqlite:///./data-dev/seismo_fleet.db"
|
||||
|
||||
def migrate_dev_database():
|
||||
print("Migrating DEV database to add SLM columns...")
|
||||
print("=" * 60)
|
||||
|
||||
engine = create_engine(DEV_DB_URL, connect_args={"check_same_thread": False})
|
||||
|
||||
# SLM columns to add
|
||||
slm_columns = [
|
||||
("slm_host", "VARCHAR"),
|
||||
("slm_tcp_port", "INTEGER"),
|
||||
("slm_model", "VARCHAR"),
|
||||
("slm_serial_number", "VARCHAR"),
|
||||
("slm_frequency_weighting", "VARCHAR"),
|
||||
("slm_time_weighting", "VARCHAR"),
|
||||
("slm_measurement_range", "VARCHAR"),
|
||||
("slm_last_check", "DATETIME"),
|
||||
]
|
||||
|
||||
with engine.connect() as conn:
|
||||
for column_name, column_type in slm_columns:
|
||||
try:
|
||||
# Try to add the column
|
||||
conn.execute(text(f"ALTER TABLE roster ADD COLUMN {column_name} {column_type}"))
|
||||
conn.commit()
|
||||
print(f"✓ Added column: {column_name}")
|
||||
except Exception as e:
|
||||
if "duplicate column name" in str(e).lower():
|
||||
print(f" Column {column_name} already exists, skipping")
|
||||
else:
|
||||
print(f"✗ Error adding {column_name}: {e}")
|
||||
|
||||
print("=" * 60)
|
||||
print("DEV database migration completed!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
migrate_dev_database()
|
||||
Reference in New Issue
Block a user