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: give safe database setup guidance for file mode (#9885)

Adam Eivy608a342c27f3
diff --git a/scripts/setup-db.js b/scripts/setup-db.js
index 02891ed146..2e9f0176fc 100644
--- a/scripts/setup-db.js
+++ b/scripts/setup-db.js
@@ -251,7 +251,12 @@ if (mode === 'file') {
// has no file-backed equivalent. Kept for development/tests.
console.error('🚫 PGMODE=file is UNSUPPORTED for production — PostgreSQL is required.');
console.error(' File-based storage has no creative-catalog or vector-search support.');
- console.log(' Switch to a supported mode with: scripts/db.sh set-mode native (or docker)');
+ console.log(' For a fresh/development install, set PGMODE=native or PGMODE=docker in the');
+ console.log(' repository-root .env, preserving other settings. Unset a conflicting exported');
+ console.log(' PGMODE, then re-run: npm run setup:db');
+ console.log(' Existing PostgreSQL installs must retain the backend holding their records;');
+ console.log(' an intentional move requires coordinated maintenance cutover.');
+ console.log(' See docs/STORAGE.md#setup-path-npm-run-setupdb.');
process.exit(0);
}
diff --git a/scripts/setup-db.test.js b/scripts/setup-db.test.js
index 12f0ded323..c3494cb9f2 100644
--- a/scripts/setup-db.test.js
+++ b/scripts/setup-db.test.js
@@ -70,6 +70,7 @@ async function runSetup({ mode = 'docker', unavailable, tty = false, nativeReady
const calls = [];
const childEnvs = [];
const errors = [];
+ const logs = [];
const exitSignal = {};
const volumeRecords = ['example persisted record'];
const container = { running, hostBinding, hostPort, volumeRecords };
@@ -91,7 +92,7 @@ async function runSetup({ mode = 'docker', unavailable, tty = false, nativeReady
env: {}, platform: 'linux', stdin: { isTTY: tty }, stdout: { isTTY: tty },
exit: (code) => { exitCode = code; throw exitSignal; }
},
- console: { log: () => {}, error: (message) => errors.push(message) },
+ console: { log: (message) => logs.push(message), error: (message) => errors.push(message) },
execFileSync: (command, args, options) => {
calls.push([command, ...args]);
childEnvs.push(options?.env);
@@ -119,10 +120,26 @@ async function runSetup({ mode = 'docker', unavailable, tty = false, nativeReady
if (error !== exitSignal) throw error;
}
expect(savedEnv).toEqual(initialEnv);
- return { exitCode, calls, childEnvs, errors, container, volumeRecords, recreations };
+ return { exitCode, calls, childEnvs, errors, logs, container, volumeRecords, recreations };
}
describe('setup preserves the selected database', () => {
+ it('gives safe initial selection guidance for unsupported file mode without running setup', async () => {
+ const result = await runSetup({ mode: 'file' });
+ expect(result.exitCode).toBe(0);
+ expect(result.calls).toEqual([]);
+ expect(result.errors.join('\n')).toContain('UNSUPPORTED for production — PostgreSQL is required');
+ const guidance = result.logs.join('\n');
+ expect(guidance).toContain('PGMODE=native or PGMODE=docker');
+ expect(guidance).toContain('repository-root .env, preserving other settings');
+ expect(guidance).toContain('Unset a conflicting exported');
+ expect(guidance).toContain('npm run setup:db');
+ expect(guidance).toContain('retain the backend holding their records');
+ expect(guidance).toContain('coordinated maintenance cutover');
+ expect(guidance).toContain('docs/STORAGE.md#setup-path-npm-run-setupdb');
+ expect(guidance).not.toMatch(/set-mode|use-native|use-docker/);
+ });
+
it.each(['docker --version', 'docker info', 'docker compose version'])(
'fails safely when %s is unavailable despite a healthy native database', async (unavailable) => {
for (const tty of [false, true]) {