|
@@ -44,7 +44,15 @@ def run_migrations():
|
|
|
# Simple splitter by semicolon (works for basic schemas)
|
|
# Simple splitter by semicolon (works for basic schemas)
|
|
|
statements = [s.strip() for s in sql.split(";") if s.strip()]
|
|
statements = [s.strip() for s in sql.split(";") if s.strip()]
|
|
|
for stmt in statements:
|
|
for stmt in statements:
|
|
|
- db.execute_commit(stmt)
|
|
|
|
|
|
|
+ try:
|
|
|
|
|
+ db.execute_commit(stmt)
|
|
|
|
|
+ except Exception as e:
|
|
|
|
|
+ # Ignore "Duplicate column name" or "Table already exists" errors
|
|
|
|
|
+ err_msg = str(e).lower()
|
|
|
|
|
+ if "duplicate column" in err_msg or "already exists" in err_msg or "duplicate key" in err_msg:
|
|
|
|
|
+ print(f" Note: Statement skipped (already applied or exists): {stmt[:50]}...")
|
|
|
|
|
+ else:
|
|
|
|
|
+ raise e
|
|
|
|
|
|
|
|
# Mark as applied
|
|
# Mark as applied
|
|
|
db.execute_commit("INSERT INTO schema_migrations (migration_name) VALUES (%s)", (filename,))
|
|
db.execute_commit("INSERT INTO schema_migrations (migration_name) VALUES (%s)", (filename,))
|