Migrations silently swallow failures — partial schema upgrades leave server running on broken DB #107

Closed
opened 2026-05-26 18:19:01 -04:00 by zgaetano · 1 comment
Owner

Fixed in 04ce096. Migrations now run through schema_migrations (filename + applied_at), each migration in its own transaction. Failures process.exit(1) unless MIGRATIONS_ALLOW_FAILURES=1 is set, so the orchestrator restarts instead of serving traffic on a broken schema. MIGRATIONS_FORCE=1 re-runs migrations when iterating locally.

Fixed in 04ce096. Migrations now run through `schema_migrations` (filename + applied_at), each migration in its own transaction. Failures `process.exit(1)` unless `MIGRATIONS_ALLOW_FAILURES=1` is set, so the orchestrator restarts instead of serving traffic on a broken schema. `MIGRATIONS_FORCE=1` re-runs migrations when iterating locally.
Author
Owner

Fix Plan — #107 Migrations silently swallow failures

Root cause: src/index.js:105-111 wraps each migration in try/catch, console.error, continues loop. Failed migration → partial schema → API starts on broken DB.

Fix:

// src/index.js:105-111
for (const migration of migrations) {
  try {
    await migration();
  } catch (err) {
    console.error("Migration failed:", err.message);
    console.error("Aborting startup. Run migrations manually.");
    process.exit(1);
  }
}

Also add retry-with-backoff (5 tries × 2s) for loadS3ConfigFromDb() at index.js:116.

Files: src/index.js:105-120
Effort: ~30min
**Priority: P0 — data integrity

## Fix Plan — #107 Migrations silently swallow failures **Root cause:** `src/index.js:105-111` wraps each migration in try/catch, console.error, continues loop. Failed migration → partial schema → API starts on broken DB. **Fix:** ```js // src/index.js:105-111 for (const migration of migrations) { try { await migration(); } catch (err) { console.error("Migration failed:", err.message); console.error("Aborting startup. Run migrations manually."); process.exit(1); } } ``` Also add retry-with-backoff (5 tries × 2s) for `loadS3ConfigFromDb()` at `index.js:116`. **Files:** `src/index.js:105-120` **Effort:** ~30min **Priority: P0 — data integrity
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: WildDragonLLC/dragonflight#107
No description provided.