from sqlalchemy import inspect, text from app.core.database import engine def run_migrations() -> None: """Apply lightweight schema updates for existing databases.""" inspector = inspect(engine) if "students" not in inspector.get_table_names(): return columns = {col["name"] for col in inspector.get_columns("students")} if "school_level" not in columns: with engine.begin() as conn: conn.execute( text( "ALTER TABLE students ADD COLUMN school_level VARCHAR(32) " "NOT NULL DEFAULT 'junior_high'" ) )