import pymysql import os DB_HOST = "mysql1.rdsmbk3ednsgnnt.rds.bj.baidubce.com" DB_PORT = 3306 DB_NAME = "case_platform" DB_USER = "root_dev" DB_PASS = "Kdse89sd" def run_migration(): try: connection = pymysql.connect( host=DB_HOST, port=DB_PORT, user=DB_USER, password=DB_PASS, database=DB_NAME, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor ) with connection.cursor() as cursor: # Check if assignees column exists in test_plans cursor.execute("SHOW COLUMNS FROM test_plans LIKE 'assignees'") result = cursor.fetchone() if not result: print("Adding 'assignees' column to 'test_plans' table...") cursor.execute("ALTER TABLE test_plans ADD COLUMN assignees JSON NULL AFTER case_ids") print("Column added successfully.") else: print("Column 'assignees' already exists in 'test_plans'.") connection.commit() except Exception as e: print(f"Migration failed: {e}") finally: if 'connection' in locals(): connection.close() if __name__ == "__main__": run_migration()