Files
echoes-of-the-ash/api/migration_add_intent.py
2025-11-27 16:27:01 +01:00

18 lines
718 B
Python

import asyncio
from sqlalchemy import text
from api.database import engine
async def migrate():
print("Starting migration: Adding npc_intent column to active_combats table...")
async with engine.begin() as conn:
try:
# Check if column exists first to avoid errors
# This is a simple check, might vary based on exact postgres version but usually works
await conn.execute(text("ALTER TABLE active_combats ADD COLUMN IF NOT EXISTS npc_intent VARCHAR DEFAULT 'attack'"))
print("Migration successful: Added npc_intent column.")
except Exception as e:
print(f"Migration failed: {e}")
if __name__ == "__main__":
asyncio.run(migrate())