#!/usr/bin/env python3 """ Update DEV database schema to match current models """ from sqlalchemy import create_engine, inspect from backend.models import Base # DEV database DEV_DB_URL = "sqlite:///./data-dev/seismo_fleet.db" def update_schema(): print("Updating DEV database schema...") print("=" * 60) engine = create_engine(DEV_DB_URL, connect_args={"check_same_thread": False}) # Create all tables (will update existing tables with new columns) Base.metadata.create_all(bind=engine) # Inspect to see what we have inspector = inspect(engine) tables = inspector.get_table_names() print(f"Tables in DEV database: {tables}") if 'roster' in tables: columns = [col['name'] for col in inspector.get_columns('roster')] print(f"\nColumns in roster table:") for col in sorted(columns): print(f" - {col}") print("=" * 60) print("DEV database schema updated successfully!") print("\nNote: SQLite doesn't support ALTER COLUMN, so existing") print("columns won't be modified, but new columns will be added.") if __name__ == "__main__": update_schema()