Spaces:
Running
Running
File size: 860 Bytes
a0c854c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import asyncio
from sqlalchemy.ext.asyncio import create_async_engine
from sqlalchemy import text
import os
DB_URL = os.getenv("DATABASE_URL", "sqlite+aiosqlite:///legacy_solver.db")
async def migrate():
print(f"Starting migration on {DB_URL}...")
engine = create_async_engine(DB_URL)
async with engine.begin() as conn:
print("Creating 'user_credentials' table if it doesn't exist...")
await conn.execute(text("""
CREATE TABLE IF NOT EXISTS user_credentials (
user_id VARCHAR(128) PRIMARY KEY,
gemini_api_key TEXT,
openrouter_api_key TEXT,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
)
"""))
await engine.dispose()
print("Migration completed successfully!")
if __name__ == "__main__":
asyncio.run(migrate())
|