Files
service-finder/backend/app/tests_internal/seeds/seed_economy.py
2026-03-13 10:22:41 +00:00

62 lines
1.9 KiB
Python

#!/usr/bin/env python3
"""
Seed script az Economy 1 modulhoz: árfolyam paraméterek beszúrása a system.system_parameters táblába.
"""
import asyncio
import sys
from decimal import Decimal
sys.path.insert(0, "/app")
from sqlalchemy import select
from app.database import AsyncSessionLocal
from app.models.system import SystemParameter
async def seed_economy():
"""Árfolyam paraméterek beszúrása."""
parameters = [
{
"key": "EXCHANGE_RATE_EUR_HUF",
"value": "390.0",
"description": "EUR/HUF átváltási árfolyam (1 EUR = X HUF)",
"category": "finance",
"is_active": True,
},
{
"key": "EXCHANGE_RATE_USDC_HUF",
"value": "380.0",
"description": "USDC/HUF átváltási árfolyam (1 USDC = X HUF)",
"category": "finance",
"is_active": True,
},
]
async with AsyncSessionLocal() as session:
for param in parameters:
# Ellenőrizzük, hogy létezik-e már
existing = await session.execute(
select(SystemParameter).where(SystemParameter.key == param["key"])
)
existing = existing.scalar_one_or_none()
if existing:
print(f"⚠️ {param['key']} már létezik, kihagyva.")
continue
new_param = SystemParameter(
key=param["key"],
value=param["value"],
description=param["description"],
category=param["category"],
is_active=param["is_active"],
)
session.add(new_param)
print(f"{param['key']} beszúrva.")
await session.commit()
print("🎉 Árfolyam paraméterek sikeresen seedelve.")
if __name__ == "__main__":
asyncio.run(seed_economy())