在前后端开发联调前 的提交20260223
This commit is contained in:
36
scripts/ops/run_migration_assistant_no_int.py
Normal file
36
scripts/ops/run_migration_assistant_no_int.py
Normal file
@@ -0,0 +1,36 @@
|
||||
"""执行 assistant_no_int 迁移脚本到测试库"""
|
||||
import os
|
||||
from pathlib import Path
|
||||
from dotenv import load_dotenv
|
||||
import psycopg2
|
||||
|
||||
load_dotenv(Path(__file__).resolve().parents[2] / ".env")
|
||||
|
||||
dsn = os.environ.get("TEST_DB_DSN")
|
||||
if not dsn:
|
||||
raise RuntimeError("TEST_DB_DSN 未配置")
|
||||
|
||||
sql_file = Path(__file__).resolve().parents[2] / "db/etl_feiqiu/migrations/2026-02-20__add_assistant_trash_event_ex_assistant_no_int.sql"
|
||||
sql = sql_file.read_text(encoding="utf-8")
|
||||
|
||||
conn = psycopg2.connect(dsn)
|
||||
conn.autocommit = True
|
||||
with conn.cursor() as cur:
|
||||
cur.execute(sql)
|
||||
print("迁移执行成功")
|
||||
|
||||
# 验证
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("""
|
||||
SELECT column_name, data_type
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = 'dwd'
|
||||
AND table_name = 'dwd_assistant_trash_event_ex'
|
||||
ORDER BY ordinal_position
|
||||
""")
|
||||
rows = cur.fetchall()
|
||||
print(f"dwd_assistant_trash_event_ex 当前列:")
|
||||
for r in rows:
|
||||
print(f" {r[0]} ({r[1]})")
|
||||
|
||||
conn.close()
|
||||
Reference in New Issue
Block a user