#!/usr/bin/env python3
"""Check existing tables"""

from sqlalchemy import create_engine, text
from app.core.config import settings

engine = create_engine(settings.database_url)

with engine.connect() as conn:
    # Get all tables
    result = conn.execute(text("SHOW TABLES"))
    tables = [row[0] for row in result.fetchall()]

    print("Existing tables:")
    for table in sorted(tables):
        print(f"  - {table}")

    # Check which V2 tables exist
    v2_tables = ['tool_ocr_users', 'tool_ocr_sessions', 'tool_ocr_tasks',
                 'tool_ocr_task_files', 'tool_ocr_audit_logs']
    print("\nV2 Tables status:")
    for table in v2_tables:
        exists = table in tables
        print(f"  {'✓' if exists else '✗'} {table}")

    # Check which old tables exist
    old_tables = ['paddle_ocr_users', 'paddle_ocr_batches', 'paddle_ocr_files',
                  'paddle_ocr_results', 'paddle_ocr_export_rules', 'paddle_ocr_translation_configs']
    print("\nOld Tables status:")
    for table in old_tables:
        exists = table in tables
        print(f"  {'✓' if exists else '✗'} {table}")
