from config import db
from app import app
from sqlalchemy import text

with app.app_context():
    try:
        db.session.execute(text('ALTER TABLE enrollments ADD COLUMN IF NOT EXISTS completed_at DATETIME NULL AFTER is_completed;'))
        db.session.commit()
        print("Column completed_at added to enrollments.")
    except Exception as e:
        print(f"Error: {e}")
