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:
parent
4cea84ebab
commit
f3144d10c5
11
server.js
11
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_mollie_id ON applications(mollie_payment_id)');
|
||||||
await pool.query('CREATE INDEX IF NOT EXISTS idx_applications_payment_status ON applications(payment_status)');
|
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');
|
console.log('Database migrations complete');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Migration error:', err.message);
|
console.error('Migration error:', err.message);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue