"""
檢查資料庫中所有 tenant_* 表
"""
import psycopg2

conn = psycopg2.connect(
    host="10.1.0.20",
    port=5433,
    database="hr_portal",
    user="admin",
    password="DC1qaz2wsx"
)
cur = conn.cursor()

cur.execute("""
    SELECT tablename
    FROM pg_tables
    WHERE schemaname = 'public'
      AND tablename LIKE 'tenant_%'
    ORDER BY tablename;
""")

tables = cur.fetchall()

print("=== Tenant Tables ===\n")

if tables:
    for t in tables:
        print(f"  - {t[0]}")
else:
    print("No tenant_* tables found")

print()

cur.close()
conn.close()
