import asyncio
from sqlalchemy import text
from app.db.session import SessionLocal

async def seed():
    async with SessionLocal() as db:
        print("🚀 Honda adatok betöltése...")
        
        # 1. Kategóriák (Autó, Motor) - Sima idézőjelekkel a SQL-ben
        await db.execute(text("""
            INSERT INTO data.vehicle_categories (name, slug) 
            VALUES (\u0027Személyautó\u0027, \u0027car\u0027), (\u0027Motorkerékpár\u0027, \u0027motorcycle\u0027)
            ON CONFLICT (slug) DO NOTHING
        """))

        # 2. Márka: Honda
        res = await db.execute(text("""
            INSERT INTO data.vehicle_brands (name, slug, country_code) 
            VALUES (\u0027Honda\u0027, \u0027honda\u0027, \u0027JP\u0027)
            ON CONFLICT (slug) DO UPDATE SET name = EXCLUDED.name
            RETURNING id
        """))
        brand_id = res.fetchone()[0]

        # 3. Modellek listája
        models = [
            ("Civic", "civic"),
            ("Accord", "accord"),
            ("CR-V", "cr-v"),
            ("Jazz", "jazz"),
            ("HR-V", "hr-v"),
            ("NSX", "nsx")
        ]
        
        for name, slug in models:
            await db.execute(text(f"""
                INSERT INTO data.vehicle_models (brand_id, name, slug) 
                VALUES ({brand_id}, \u0027{name}\u0027, \u0027{slug}\u0027)
                ON CONFLICT (brand_id, slug) DO NOTHING
            """))

        await db.commit()
        print("✅ Honda márka és modellek sikeresen betöltve!")

if __name__ == "__main__":
    asyncio.run(seed())
