#!/usr/bin/env python3 """ Проверка схемы базы данных """ import asyncio import sys import os sys.path.insert(0, os.path.dirname(__file__)) from src.core.database import engine from sqlalchemy import text async def check_database_schema(): """Проверка схемы базы данных""" print("🔍 Проверяем схему базы данных...") async with engine.begin() as conn: # Проверяем колонки таблицы users result = await conn.execute(text( "SELECT column_name, data_type, is_nullable " "FROM information_schema.columns " "WHERE table_name = 'users' AND table_schema = 'public' " "ORDER BY column_name;" )) print("\n📊 Колонки в таблице 'users':") print("-" * 50) columns = result.fetchall() for column_name, data_type, is_nullable in columns: nullable = "NULL" if is_nullable == "YES" else "NOT NULL" print(f" {column_name:<20} {data_type:<15} {nullable}") # Проверяем, есть ли поле phone phone_exists = any(col[0] == 'phone' for col in columns) if phone_exists: print("\n✅ Поле 'phone' найдено в базе данных") else: print("\n❌ Поле 'phone' НЕ найдено в базе данных") # Проверяем, есть ли поле verification_code verification_code_exists = any(col[0] == 'verification_code' for col in columns) if verification_code_exists: print("✅ Поле 'verification_code' найдено в базе данных") else: print("❌ Поле 'verification_code' НЕ найдено в базе данных") async def main(): """Основная функция""" try: await check_database_schema() except Exception as e: print(f"❌ Ошибка при проверке базы данных: {e}") finally: await engine.dispose() if __name__ == "__main__": asyncio.run(main())