import asyncio
import sys
import os

sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from sqlalchemy import select, delete, insert
from app.core.database import AsyncSessionLocal
from app.models.sales_models import CustomerTypeMaster

async def run():
    async with AsyncSessionLocal() as db:
        # We can just add DEALER and DIRECT if they don't exist
        existing = await db.scalars(select(CustomerTypeMaster))
        types = [t.type_code for t in existing]
        
        if 'DEALER' not in types:
            db.add(CustomerTypeMaster(type_code='DEALER', name='Dealer'))
        if 'DIRECT' not in types:
            db.add(CustomerTypeMaster(type_code='DIRECT', name='Direct Customer'))
            
        await db.commit()
        print("Updated customer_type_master")

if __name__ == '__main__':
    asyncio.run(run())
