From f3144d10c582e7e6863a55db260145cf40bda4ed Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Mon, 23 Feb 2026 21:10:01 -0800 Subject: [PATCH] =?UTF-8?q?fix:=20rename=20email=5Flog.resend=5Fid=20?= =?UTF-8?q?=E2=86=92=20message=5Fid=20in=20auto-migration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The live DB has the legacy column name 'resend_id' but the code references 'message_id'. Adds a migration that detects and renames the column on startup. Co-Authored-By: Claude Opus 4.6 --- server.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/server.js b/server.js index c3ae2a7..77fc219 100644 --- a/server.js +++ b/server.js @@ -75,6 +75,17 @@ async function runMigrations() { `); await pool.query('CREATE INDEX IF NOT EXISTS idx_applications_mollie_id ON applications(mollie_payment_id)'); await pool.query('CREATE INDEX IF NOT EXISTS idx_applications_payment_status ON applications(payment_status)'); + + // Rename resend_id → message_id in email_log (legacy column name) + const colCheck = await pool.query(` + SELECT column_name FROM information_schema.columns + WHERE table_name = 'email_log' AND column_name = 'resend_id' + `); + if (colCheck.rows.length > 0) { + await pool.query('ALTER TABLE email_log RENAME COLUMN resend_id TO message_id'); + console.log('Renamed email_log.resend_id → message_id'); + } + console.log('Database migrations complete'); } catch (err) { console.error('Migration error:', err.message);