From 69a3c834361cea30588efb804b11d9aaacd9d9d6 Mon Sep 17 00:00:00 2001 From: Michelle Date: Tue, 24 Feb 2026 19:47:23 +0100 Subject: [PATCH] fix branding --- server/routes/branding.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/server/routes/branding.js b/server/routes/branding.js index f50c20a..56be9ff 100644 --- a/server/routes/branding.js +++ b/server/routes/branding.js @@ -50,12 +50,11 @@ async function getSetting(key) { // Helper: set setting in DB async function setSetting(key, value) { const db = getDb(); - // Upsert - const existing = await db.get('SELECT key FROM settings WHERE key = ?', [key]); - if (existing) { - await db.run('UPDATE settings SET value = ?, updated_at = CURRENT_TIMESTAMP WHERE key = ?', [value, key]); - } else { - await db.run('INSERT INTO settings (key, value) VALUES (?, ?)', [key, value]); + // Try update first, then insert if nothing was updated + const result = await db.run('UPDATE settings SET value = ?, updated_at = CURRENT_TIMESTAMP WHERE key = ?', [value, key]); + if (result.changes === 0) { + // Use INSERT with a dummy RETURNING to satisfy PG adapter, or just use exec-style + await db.run('INSERT INTO settings (key, value) VALUES (?, ?) RETURNING key', [key, value]); } }