fix: rename email_log.resend_id → message_id in auto-migration

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 <noreply@anthropic.com>
This commit is contained in:
Jeff Emmett 2026-02-23 21:10:01 -08:00
parent 4cea84ebab
commit f3144d10c5
1 changed files with 11 additions and 0 deletions

View File

@ -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);