27 lines
1.0 KiB
Python
27 lines
1.0 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Manuálisan létrehozza a TCO táblákat, ha a migráció nem működik.
|
|
"""
|
|
import asyncio
|
|
import sys
|
|
from sqlalchemy import text
|
|
from app.database import engine, Base
|
|
from app.models.vehicle import CostCategory, VehicleCost
|
|
|
|
async def create_tables():
|
|
print("Creating TCO tables...")
|
|
async with engine.begin() as conn:
|
|
# Ellenőrizzük, hogy a 'vehicle' séma létezik-e
|
|
await conn.execute(text("CREATE SCHEMA IF NOT EXISTS vehicle"))
|
|
# Táblák létrehozása a metaadatok alapján
|
|
await conn.run_sync(Base.metadata.create_all)
|
|
print("Tables created (or already exist).")
|
|
|
|
# Ellenőrzés
|
|
result = await conn.execute(text("SELECT table_name FROM information_schema.tables WHERE table_schema = 'vehicle' AND table_name IN ('cost_categories', 'costs')"))
|
|
tables = result.fetchall()
|
|
print(f"Found tables: {tables}")
|
|
|
|
if __name__ == "__main__":
|
|
sys.path.insert(0, '/opt/docker/dev/service_finder/backend')
|
|
asyncio.run(create_tables()) |