import asyncio
from common.sqlite_client import init_sqlite, close_sqlite, sqlite_client

async def migrate():
    await init_sqlite()
    try:
        queries = [
            "ALTER TABLE cuccu_team_memos ADD COLUMN status TEXT DEFAULT 'draft'",
            "ALTER TABLE cuccu_team_memos ADD COLUMN pinned INTEGER DEFAULT 0",
            "ALTER TABLE cuccu_team_memos ADD COLUMN merged_at TIMESTAMP",
            "ALTER TABLE cuccu_team_memos ADD COLUMN merged_by TEXT",
            "ALTER TABLE cuccu_team_memos ADD COLUMN review_reason TEXT"
        ]
        for query in queries:
            try:
                await sqlite_client.execute(query)
                print("Executed:", query)
            except Exception as e:
                print("Failed to execute", query, e)
    finally:
        await close_sqlite()

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