"""检查 dws schema 中所有 site_id 仍为 integer 的表"""
import os
from pathlib import Path
from dotenv import load_dotenv
import psycopg2

load_dotenv(Path(__file__).resolve().parents[2] / ".env")
conn = psycopg2.connect(os.environ["PG_DSN"], connect_timeout=5)
cur = conn.cursor()
cur.execute("""
    SELECT table_schema, table_name, column_name, data_type
    FROM information_schema.columns
    WHERE column_name = 'site_id' AND data_type = 'integer'
      AND table_schema IN ('dws', 'dwd', 'ods', 'quality')
    ORDER BY table_schema, table_name
""")
rows = cur.fetchall()
print(f"site_id 仍为 integer 的表 ({len(rows)}):")
for r in rows:
    print(f"  {r[0]}.{r[1]}.{r[2]} = {r[3]}")
conn.close()
