"""
檢查 tenant_user_roles 表結構
"""
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 column_name, data_type, is_nullable, column_default
    FROM information_schema.columns
    WHERE table_name = 'tenant_user_roles'
    ORDER BY ordinal_position;
""")

columns = cur.fetchall()
print("tenant_user_roles 表結構:\n")
for col in columns:
    print(f"  {col[0]:<20} {col[1]:<20} NULL={col[2]:<5} DEFAULT={col[3]}")

cur.close()
conn.close()
