import asyncio
import sys
from sqlalchemy.ext.asyncio import create_async_engine
from app.core.config import settings

async def main():
    try:
        engine = create_async_engine(settings.DATABASE_URL)
        async with engine.begin() as conn:
            from sqlalchemy import text
            await conn.execute(text("ALTER TABLE project_detail_tb MODIFY site_id INT NULL;"))
            await conn.execute(text("ALTER TABLE project_detail_tb MODIFY task_id INT NULL;"))
            print("Successfully updated project_detail_tb to allow NULL values for site_id and task_id.")
    except Exception as e:
        print(f"Error: {e}")

if __name__ == "__main__":
    asyncio.run(main())
