From fd737f86583af01acc514146be20d95b58ee8cb9 Mon Sep 17 00:00:00 2001 From: chahinebrini Date: Sat, 9 May 2026 20:57:14 +0200 Subject: [PATCH] fix(imap-idle): use snake_case table + columns (match Prisma @map) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Daemon SQL used PascalCase "MailConnection" + camelCase column-names that match the Prisma model field-names — but actual DB has snake_case table "mail_connections" with snake_case columns (per @map decorators). Result: daemon was online but ALL queries failed with relation "rebreak.MailConnection" does not exist → no mailboxes loaded → no IDLE-sessions established. Fix: query "rebreak.mail_connections" with snake_case columns, alias back to camelCase via SQL AS so rest of the daemon code works unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) --- backend/imap-idle/index.mjs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/backend/imap-idle/index.mjs b/backend/imap-idle/index.mjs index bc22c58..42e5281 100644 --- a/backend/imap-idle/index.mjs +++ b/backend/imap-idle/index.mjs @@ -44,11 +44,19 @@ const RECONNECT_LOOP_DELAY_MS = 60 * 1000; const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL }); async function loadActiveConnections() { + // DB-table heißt "mail_connections" + snake_case columns (Prisma @map). + // Aliase auf camelCase damit der restliche Daemon-Code unverändert bleibt. const { rows } = await pool.query( - `SELECT id, "userId", email, "imapHost", "imapPort", - "passwordEncrypted", "rejectUnauthorized", "useStarttls" - FROM rebreak."MailConnection" - WHERE "isActive" = true`, + `SELECT id, + user_id AS "userId", + email, + imap_host AS "imapHost", + imap_port AS "imapPort", + password_encrypted AS "passwordEncrypted", + reject_unauthorized AS "rejectUnauthorized", + use_starttls AS "useStarttls" + FROM rebreak.mail_connections + WHERE is_active = true`, ); return rows; }