import psycopg2

conn = psycopg2.connect(
    host="192.168.1.85",
    port=5432,
    user="admin",
    password="admin_password_2026",
    dbname="lubrication_crm",
)
cur = conn.cursor()

# Check table structures
for t in ["users", "clients", "follow_ups", "expenses"]:
    cur.execute(f"""
        SELECT column_name, data_type, is_nullable, column_default
        FROM information_schema.columns
        WHERE table_name = '{t}'
        ORDER BY ordinal_position
    """)
    print(f"\n=== {t} ===")
    for row in cur.fetchall():
        print(f"  {row[0]:20s} | {row[1]:20s} | null={row[2]} | default={row[3]}")

    # Check constraints
    cur.execute(f"""
        SELECT conname, contype
        FROM pg_constraint
        JOIN pg_class ON conrelid = pg_class.oid
        WHERE pg_class.relname = '{t}'
    """)
    constraints = cur.fetchall()
    if constraints:
        print(f"  Constraints: {constraints}")

conn.close()
