chore: Backend codebase cleanup and archiving of legacy scripts
This commit is contained in:
27
backend/archive_v1_scripts/create_tco_tables.py
Normal file
27
backend/archive_v1_scripts/create_tco_tables.py
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/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())
|
||||
Reference in New Issue
Block a user