Skip to content

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

fix: keep database maintenance direction on the saved mode when PGMODE is exported (#10758)

Adam Eivy915e754d5138
diff --git a/scripts/database-maintenance.mjs b/scripts/database-maintenance.mjs
index c2f6c86bd7..3adcbb37ed 100644
--- a/scripts/database-maintenance.mjs
+++ b/scripts/database-maintenance.mjs
@@ -15,7 +15,15 @@ const journal = createDatabaseMaintenanceJournal();
const require = createRequire(import.meta.url);
function configuredEndpoints() {
- const { DATABASE_MODE, DATABASE_ENDPOINTS } = require(join(PATHS.installRoot, 'ecosystem.config.cjs'));
+ // Maintenance direction follows the SAVED mode: a stale exported PGMODE (which
+ // the ecosystem now honors for launches, #10758) must not redefine the source.
+ const exportedMode = process.env.PGMODE;
+ delete process.env.PGMODE;
+ let loaded;
+ try { loaded = require(join(PATHS.installRoot, 'ecosystem.config.cjs')); } finally {
+ if (exportedMode !== undefined) process.env.PGMODE = exportedMode;
+ }
+ const { DATABASE_MODE, DATABASE_ENDPOINTS } = loaded;
if (!['native', 'docker'].includes(DATABASE_MODE) || !DATABASE_ENDPOINTS) {
throw new Error('Database configuration is not a supported backend.');
}