#!/usr/bin/env python3 """ Migration: Drop valid_damage constraint from player_status_effects table. This constraint prevents negative damage (healing) for status effects. """ import asyncio import os import sys # Add parent directory to path sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from sqlalchemy.ext.asyncio import create_async_engine from sqlalchemy import text DB_USER = os.getenv("POSTGRES_USER") DB_PASS = os.getenv("POSTGRES_PASSWORD") DB_NAME = os.getenv("POSTGRES_DB") DB_HOST = os.getenv("POSTGRES_HOST", "echoes_of_the_ashes_db") DB_PORT = os.getenv("POSTGRES_PORT", "5432") DATABASE_URL = f"postgresql+psycopg://{DB_USER}:{DB_PASS}@{DB_HOST}:{DB_PORT}/{DB_NAME}" async def run_migration(): engine = create_async_engine(DATABASE_URL, echo=True) async with engine.begin() as conn: print("Removing restrictive constraint from player_status_effects table...") try: await conn.execute(text(""" ALTER TABLE player_status_effects DROP CONSTRAINT IF EXISTS valid_damage """)) print("āœ“ Dropped valid_damage constraint") except Exception as e: print(f"Error dropping constraint: {e}") print("\nāœ“ Migration completed successfully!") await engine.dispose() if __name__ == "__main__": asyncio.run(run_migration())