import psycopg

conn = psycopg.connect(
    host='192.168.0.61',
    port=55432,
    dbname='njts_acct',
    user='njts_app',
    password='njts_app2025'
)

cur = conn.cursor()

# ALTER TABLE実行
cur.execute("""
    ALTER TABLE employees 
      ALTER COLUMN photo_url TYPE TEXT,
      ALTER COLUMN my_number_card_image_url TYPE TEXT,
      ALTER COLUMN residence_card_image_url TYPE TEXT,
      ALTER COLUMN health_insurance_card_image_url TYPE TEXT,
      ALTER COLUMN other_id_image_url TYPE TEXT
""")
conn.commit()

print('写真カラムのデータ型をTEXTに変更しました')

# 確認
cur.execute("""
    SELECT column_name, data_type, character_maximum_length 
    FROM information_schema.columns 
    WHERE table_name = 'employees' 
      AND column_name LIKE '%_url'
    ORDER BY column_name
""")

result = cur.fetchall()
print('\nカラム情報:')
for r in result:
    length = r[2] if r[2] else '制限なし'
    print(f'  {r[0]}: {r[1]} ({length})')

cur.close()
conn.close()
