Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): run idempotent schema upgrade before boot fail-fast
Adam Eivye0d7f514f204
diff --git a/server/index.js b/server/index.jsindex 2e6a06d877..7f964ec2af 100644--- a/server/index.js+++ b/server/index.js@@ -771,7 +771,24 @@ ensureSelf()const dbEscapeHatch =process.env.MEMORY_BACKEND === 'file' || process.env.NODE_ENV === 'test';const { checkHealth, ensureSchema } = await import('./lib/db.js');- const health = await checkHealth();+ let health = await checkHealth();+ // An EXISTING install can be reachable but lag the current schema — e.g.+ // `memories` exists but a newer column (`sync_sequence`) is missing, which+ // is exactly what checkHealth() requires for hasSchema. ensureSchema() is+ // idempotent and exists to bring such installs up to date, so when the DB+ // is connected but reports incomplete schema, run the upgrade and re-probe+ // BEFORE declaring the install unbootable. A truly uninitialized DB (base+ // tables absent) makes ensureSchema() throw — we catch, log, and fall+ // through to the fail-fast below. (try/catch is appropriate here: this runs+ // outside the request lifecycle, so an uncaught throw would crash boot.)+ if (health.connected && !health.hasSchema) {+ try {+ await ensureSchema();+ health = await checkHealth();+ } catch (err) {+ console.error(`🗄️ Schema upgrade on boot failed: ${err.message}`);+ }+ }const dbReady = health.connected && health.hasSchema;if (!dbEscapeHatch && !dbReady) {const reason = health.connected ? 'required schema missing' : `unreachable (${health.error || 'connection failed'})`;