Spaces:
Runtime error
Runtime error
Download fix_enum_values.py from Antaram/pratikbackend: direct link, hf CLI and curl.
- Browser
- Download file 880 Bytes
-
https://huggingface.co/spaces/Antaram/pratikbackend/resolve/main/fix_enum_values.py
- Command line
-
hf download hf://spaces/Antaram/pratikbackend/fix_enum_values.py
-
curl -L -o fix_enum_values.py https://huggingface.co/spaces/Antaram/pratikbackend/resolve/main/fix_enum_values.py
880 Bytes
| 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()) | |