# /opt/docker/dev/service_finder/backend/app/scripts/seed_v1_9_system.py
import asyncio
from sqlalchemy import select
from app.db.session import SessionLocal
from app.models import VehicleType, FeatureDefinition

async def seed_system_data():
    """ Alapvető típusok és extrák (Features) feltöltése. """
    async with SessionLocal() as db:
        try:
            print("🚀 Rendszer-blueprint betöltése...")
            
            types_data = [
                {"code": "car", "name": "Személyautó", "icon": "directions_car"},
                {"code": "motorcycle", "name": "Motorkerékpár", "icon": "moped"},
                {"code": "truck", "name": "Teherautó", "icon": "local_shipping"},
                {"code": "boat", "name": "Hajó", "icon": "sailing"}
            ]

            for t_info in types_data:
                stmt = select(VehicleType).where(VehicleType.code == t_info["code"])
                if not (await db.execute(stmt)).scalar_one_or_none():
                    db.add(VehicleType(**t_info))
            
            await db.commit()
            print("✅ Blueprint kész.")
        except Exception as e:
            print(f"❌ Hiba: {e}")

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