import psycopg2
from database import DB_CONFIG

try:
    print("正在连接数据库，准备添加上限值字段...")
    conn = psycopg2.connect(**DB_CONFIG)
    cursor = conn.cursor()
    
    cursor.execute("ALTER TABLE tb_asset_metric_bind ADD COLUMN upper_limit FLOAT;")
    conn.commit()
    
    print("已成功为 tb_asset_metric_bind 表增加 upper_limit 列。")

except psycopg2.errors.DuplicateColumn:
    print("upper_limit 列已经存在，无需重复添加。")
except Exception as e:
    print(f"执行失败：{str(e)}")
finally:
    if 'cursor' in locals(): cursor.close()
    if 'conn' in locals(): conn.close()
