Spaces:
Sleeping
Sleeping
| import asyncio | |
| from sqlalchemy import text | |
| from app.core.database import engine | |
| async def fix_enum(): | |
| async with engine.begin() as conn: | |
| # Drop and recreate enum with correct lowercase values | |
| # First, alter the column to use text temporarily | |
| await conn.execute(text("ALTER TABLE parties ALTER COLUMN party_type TYPE TEXT")) | |
| # Drop the old enum | |
| await conn.execute(text("DROP TYPE IF EXISTS partytype CASCADE")) | |
| # Create new enum with lowercase values | |
| await conn.execute(text("CREATE TYPE partytype AS ENUM ('awaak', 'jawaak', 'patti_awaak', 'both')")) | |
| # Alter column back to enum | |
| await conn.execute(text("ALTER TABLE parties ALTER COLUMN party_type TYPE partytype USING party_type::partytype")) | |
| print('Fixed enum values to lowercase') | |
| asyncio.run(fix_enum()) | |