微信小程序页面迁移校验之前 P5任务处理之前
This commit is contained in:
27
scripts/ops/_fix_spi_site_id.py
Normal file
27
scripts/ops/_fix_spi_site_id.py
Normal file
@@ -0,0 +1,27 @@
|
||||
"""修复 dws_member_spending_power_index.site_id 列类型: integer → bigint"""
|
||||
import os
|
||||
from pathlib import Path
|
||||
from dotenv import load_dotenv
|
||||
import psycopg2
|
||||
|
||||
load_dotenv(Path(__file__).resolve().parents[2] / ".env")
|
||||
dsn = os.environ["PG_DSN"]
|
||||
conn = psycopg2.connect(dsn, connect_timeout=10)
|
||||
conn.autocommit = True
|
||||
cur = conn.cursor()
|
||||
|
||||
print("修复 site_id 列类型...")
|
||||
cur.execute("ALTER TABLE dws.dws_member_spending_power_index ALTER COLUMN site_id TYPE bigint")
|
||||
print("完成: site_id 已改为 bigint")
|
||||
|
||||
# 验证
|
||||
cur.execute("""
|
||||
SELECT column_name, data_type
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema='dws' AND table_name='dws_member_spending_power_index'
|
||||
AND column_name='site_id'
|
||||
""")
|
||||
r = cur.fetchone()
|
||||
print(f"验证: {r[0]} = {r[1]}")
|
||||
|
||||
conn.close()
|
||||
Reference in New Issue
Block a user