From d40c5ce7a6a1167b30bf7197bfae667e3cfe033e Mon Sep 17 00:00:00 2001 From: Maurice Date: Wed, 17 Jun 2026 15:01:41 +0200 Subject: [PATCH] fix(demo): skip first-run admin seed in demo mode When DEMO_MODE is on, the demo seeder creates its own admin (admin@trek.app, username "admin") right after the generic seeds run. The first-run admin bootstrap was grabbing username "admin" first, so the demo seeder hit the UNIQUE(username) constraint and aborted before the demo user was ever created - which surfaced as a 500 "Demo user not found" on demo-login. Skip the generic admin bootstrap when demo mode owns the admin account. --- server/src/db/seeds.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/src/db/seeds.ts b/server/src/db/seeds.ts index c089d34b..76d40a75 100644 --- a/server/src/db/seeds.ts +++ b/server/src/db/seeds.ts @@ -18,6 +18,11 @@ function seedAdminAccount(db: Database.Database): void { const userCount = (db.prepare('SELECT COUNT(*) as count FROM users').get() as { count: number }).count; if (userCount > 0) return; + // Demo mode seeds its own admin (admin@trek.app, username 'admin') right after this. + // Creating a first-run admin here would grab username 'admin' first and make the demo + // seeder fail on the UNIQUE(username) constraint, leaving the demo user uncreated. + if (process.env.DEMO_MODE?.toLowerCase() === 'true') return; + if (isOidcOnlyConfigured()) { console.log(''); console.log('╔══════════════════════════════════════════════╗');