
#!/usr/bin/env python3
"""
Quick fix for missing contractor_rated and worker_rated columns
"""

import os
from app import create_app
from app.extensions import db

def fix_missing_columns():
    app = create_app()
    
    with app.app_context():
        try:
            # Add the missing columns
            with db.engine.connect() as connection:
                connection.execute(db.text("""
                    ALTER TABLE contracts 
                    ADD COLUMN IF NOT EXISTS contractor_rated BOOLEAN DEFAULT FALSE NOT NULL;
                """))
                
                connection.execute(db.text("""
                    ALTER TABLE contracts 
                    ADD COLUMN IF NOT EXISTS worker_rated BOOLEAN DEFAULT FALSE NOT NULL;
                """))
                
                connection.execute(db.text("""
                    ALTER TABLE contracts 
                    ADD COLUMN IF NOT EXISTS mutual_rating_completed_date TIMESTAMP;
                """))
                
                connection.commit()
            
            print("✅ Missing columns added successfully!")
            
        except Exception as e:
            print(f"❌ Error: {e}")

if __name__ == "__main__":
    fix_missing_columns()
