Files
dreamweaver/backend/scripts/add_config_column.py
torin b8d3cb4644
Some checks are pending
Build and Push Docker Images / changes (push) Waiting to run
Build and Push Docker Images / build-backend (push) Blocked by required conditions
Build and Push Docker Images / build-frontend (push) Blocked by required conditions
Build and Push Docker Images / build-admin-frontend (push) Blocked by required conditions
wip: snapshot full local workspace state
2026-04-17 18:58:11 +08:00

28 lines
1.0 KiB
Python

import asyncio
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from app.db.database import async_engine
from sqlalchemy import text
async def upgrade_db():
print("🚀 Checking database schema...")
async with async_engine.begin() as conn:
# Check if column exists
result = await conn.execute(text(
"SELECT column_name FROM information_schema.columns WHERE table_name='providers' AND column_name='config_json';"
))
if result.scalar():
print("✅ Column 'config_json' already exists.")
else:
print("⚠️ Column 'config_json' missing. Adding it now...")
await conn.execute(text("ALTER TABLE providers ADD COLUMN config_json JSON;"))
print("✅ Column 'config_json' added successfully.")
if __name__ == "__main__":
if sys.platform == 'win32':
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
asyncio.run(upgrade_db())