|
|
@@ -0,0 +1,44 @@
|
|
|
+import pymysql
|
|
|
+import os
|
|
|
+
|
|
|
+def migrate():
|
|
|
+ try:
|
|
|
+ conn = pymysql.connect(
|
|
|
+ host='rm-t4n8oyqunr5b4461s6o.mysql.singapore.rds.aliyuncs.com',
|
|
|
+ port=3306,
|
|
|
+ user='developer_saas',
|
|
|
+ password='developer_saas#Aiddit',
|
|
|
+ db='data_nexus'
|
|
|
+ )
|
|
|
+ with conn.cursor() as cursor:
|
|
|
+ print("Connected to DB")
|
|
|
+
|
|
|
+ # 1. Add commit_message to data_records
|
|
|
+ try:
|
|
|
+ cursor.execute("ALTER TABLE data_records ADD COLUMN commit_message TEXT DEFAULT NULL;")
|
|
|
+ print("Added commit_message to data_records")
|
|
|
+ except Exception as e:
|
|
|
+ print(f"Skipping data_records.commit_message: {e}")
|
|
|
+
|
|
|
+ # 2. Add commit_message to data_versions
|
|
|
+ try:
|
|
|
+ cursor.execute("ALTER TABLE data_versions ADD COLUMN commit_message TEXT DEFAULT NULL;")
|
|
|
+ print("Added commit_message to data_versions")
|
|
|
+ except Exception as e:
|
|
|
+ print(f"Skipping data_versions.commit_message: {e}")
|
|
|
+
|
|
|
+ # 3. Add content_hash to data_records
|
|
|
+ try:
|
|
|
+ cursor.execute("ALTER TABLE data_records ADD COLUMN content_hash VARCHAR(64) DEFAULT NULL;")
|
|
|
+ print("Added content_hash to data_records")
|
|
|
+ except Exception as e:
|
|
|
+ print(f"Skipping data_records.content_hash: {e}")
|
|
|
+
|
|
|
+ conn.commit()
|
|
|
+ conn.close()
|
|
|
+ print("Migration done")
|
|
|
+ except Exception as e:
|
|
|
+ print(f"Global error: {e}")
|
|
|
+
|
|
|
+if __name__ == "__main__":
|
|
|
+ migrate()
|