from sqlalchemy import create_engine, inspect
from app.config import DATABASE_URL, TABLE_PREFIX

def inspect_schema():
    engine = create_engine(DATABASE_URL)
    inspector = inspect(engine)
    tables = [
        f"{TABLE_PREFIX}DIT_Records",
        f"{TABLE_PREFIX}Sample_Records",
        f"{TABLE_PREFIX}Order_Records",
        f"{TABLE_PREFIX}Match_Results"
    ]
    
    print("All tables:", inspector.get_table_names())
    for table_name in tables:
        if table_name in inspector.get_table_names():
            print(f"\nTable {table_name} exists. Columns:")
            columns = inspector.get_columns(table_name)
            for column in columns:
                print(f"- {column['name']} ({column['type']})")
        else:
            print(f"\nTable {table_name} does not exist.")

if __name__ == "__main__":
    inspect_schema()
