40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Add slm_ftp_port column to roster table for FTP data retrieval port
|
|
"""
|
|
|
|
from sqlalchemy import create_engine, text
|
|
import os
|
|
|
|
# Determine database based on environment
|
|
ENVIRONMENT = os.getenv("ENVIRONMENT", "production")
|
|
if ENVIRONMENT == "development":
|
|
DB_URL = "sqlite:///./data-dev/seismo_fleet.db"
|
|
else:
|
|
DB_URL = "sqlite:///./data/seismo_fleet.db"
|
|
|
|
def add_ftp_port_column():
|
|
print(f"Adding slm_ftp_port column to {DB_URL}...")
|
|
print("=" * 60)
|
|
|
|
engine = create_engine(DB_URL, connect_args={"check_same_thread": False})
|
|
|
|
with engine.connect() as conn:
|
|
try:
|
|
# Try to add the column
|
|
conn.execute(text("ALTER TABLE roster ADD COLUMN slm_ftp_port INTEGER"))
|
|
conn.commit()
|
|
print("✓ Added column: slm_ftp_port (INTEGER)")
|
|
except Exception as e:
|
|
if "duplicate column name" in str(e).lower():
|
|
print(" Column slm_ftp_port already exists, skipping")
|
|
else:
|
|
print(f"✗ Error adding slm_ftp_port: {e}")
|
|
raise
|
|
|
|
print("=" * 60)
|
|
print("Migration completed!")
|
|
|
|
if __name__ == "__main__":
|
|
add_ftp_port_column()
|