2026.06.04 frontend építés közben
This commit is contained in:
52
backend/scripts/check_schema.py
Normal file
52
backend/scripts/check_schema.py
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
import asyncio
|
||||
import sys
|
||||
import os
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
from sqlalchemy import text, inspect
|
||||
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from app.core.config import settings
|
||||
|
||||
async def check_schema():
|
||||
engine = create_async_engine(settings.DATABASE_URL, echo=False)
|
||||
async_session = sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
|
||||
|
||||
async with async_session() as session:
|
||||
# Get columns of vehicle.assets
|
||||
query = text("""
|
||||
SELECT column_name, data_type
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = 'vehicle' AND table_name = 'assets'
|
||||
ORDER BY ordinal_position;
|
||||
""")
|
||||
result = await session.execute(query)
|
||||
columns = result.fetchall()
|
||||
print("Columns in vehicle.assets:")
|
||||
for col in columns:
|
||||
print(f" {col[0]} ({col[1]})")
|
||||
|
||||
# Check if owner_user_id exists
|
||||
owner_exists = any(col[0] == 'owner_user_id' for col in columns)
|
||||
print(f"\nowner_user_id exists: {owner_exists}")
|
||||
|
||||
# Find alternative column names
|
||||
alt_columns = [col[0] for col in columns if 'user' in col[0] or 'owner' in col[0]]
|
||||
print(f"\nPossible owner/user columns: {alt_columns}")
|
||||
|
||||
# Also check identity.users email column
|
||||
query2 = text("""
|
||||
SELECT column_name, data_type
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = 'identity' AND table_name = 'users'
|
||||
AND column_name = 'email';
|
||||
""")
|
||||
result2 = await session.execute(query2)
|
||||
email_col = result2.fetchone()
|
||||
print(f"\nidentity.users email column: {email_col}")
|
||||
|
||||
await engine.dispose()
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(check_schema())
|
||||
Reference in New Issue
Block a user