File size: 880 Bytes
7647b38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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())