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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user