fix(migration): apply schema fixes statement-by-statement, tolerating already-applied changes

The bulk `mysql < file.sql` run aborted on the first "duplicate column"
error because some columns from an earlier partial run already existed.
apply_sql_tolerant.sh now runs each ALTER separately and only skips
MySQL errors 1060/1061/1091/1050 (duplicate column/key, missing to drop,
table exists) — any other error still stops the migration immediately.
This commit is contained in:
Hamza-Ayed
2026-07-29 17:04:05 +03:00
parent ffedd458cb
commit 8df0f92fcf
2 changed files with 57 additions and 3 deletions
+4 -3
View File
@@ -143,11 +143,12 @@ $DC exec -T mysql mysqldump -uroot -p"$ROOT_PW" --single-transaction --routines
echo " ✔ $(du -h "$BACKUP" | cut -f1)"
# ── 5) إصلاحات المخطط ───────────────────────────────────────
# تُطبَّق عبارة-عبارة وتتجاوز فقط "موجود مسبقاً" — يجعل التشغيل قابلاً
# لإعادة المحاولة إن كانت المايغريشن قد طُبِّقت جزئياً من قبل.
echo
echo "── [5/8] applying schema fixes"
$DC exec -T mysql mysql -uroot -p"$ROOT_PW" "$DST_DB" \
< "$REPO/backend/migrations/2026_07_29_v2_migration_schema_fixes.sql"
echo " ✔ applied"
bash "$REPO/backend/scripts/apply_sql_tolerant.sh" mysql "$ROOT_PW" "$DST_DB" \
"$REPO/backend/migrations/2026_07_29_v2_migration_schema_fixes.sql"
# ── 6) فحص المفتاح ──────────────────────────────────────────
echo