From b97e139ef8771a1b04ea76bd299c922433ca456a Mon Sep 17 00:00:00 2001 From: martbost Date: Fri, 11 Sep 2026 08:10:19 -0500 Subject: [PATCH] Hotfix: quote reserved column name lead in lead_marks (MySQL 8 boot failure) Co-Authored-By: Claude Fable 5.1 --- db.js | 2 +- tank.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db.js b/db.js index a42f1c4..987a77c 100644 --- a/db.js +++ b/db.js @@ -147,7 +147,7 @@ async function bootstrap() { INDEX (adoptee), INDEX (adopter), INDEX (status) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4`); // holding-tank adoptions await q(`CREATE TABLE IF NOT EXISTS lead_marks ( - lead VARCHAR(190) PRIMARY KEY, sponsor VARCHAR(190) NULL, contacted_ts BIGINT NULL, warned_ts BIGINT NULL + \`lead\` VARCHAR(190) PRIMARY KEY, sponsor VARCHAR(190) NULL, contacted_ts BIGINT NULL, warned_ts BIGINT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4`); // dormant-lead rescue: manual "contacted" marks + warning sent await q(`CREATE TABLE IF NOT EXISTS prospects ( id INT AUTO_INCREMENT PRIMARY KEY, diff --git a/tank.js b/tank.js index a403001..3bdef43 100644 --- a/tank.js +++ b/tank.js @@ -47,10 +47,10 @@ const D = { async setStatus(id, status) { await db.q('UPDATE adoptions SET status=?, closed=? WHERE id=?', [status, Date.now(), Number(id)]); }, async recent(n) { return (await db.q('SELECT * FROM adoptions ORDER BY id DESC LIMIT ?', [Number(n) || 100])).map(rowA); }, async hasRecord(adoptee) { const r = await db.q("SELECT COUNT(*) n FROM adoptions WHERE adoptee=? AND status<>'released'", [adoptee]); return Number(r[0].n) > 0; }, - async mark(lead) { const r = await db.q('SELECT * FROM lead_marks WHERE lead=?', [lead]); return r[0] ? { sponsor: r[0].sponsor, contacted: Number(r[0].contacted_ts || 0), warned: Number(r[0].warned_ts || 0) } : null; }, + async mark(lead) { const r = await db.q('SELECT * FROM lead_marks WHERE `lead`=?', [lead]); return r[0] ? { sponsor: r[0].sponsor, contacted: Number(r[0].contacted_ts || 0), warned: Number(r[0].warned_ts || 0) } : null; }, async setMark(lead, f) { const cur = (await this.mark(lead)) || {}; const m = Object.assign(cur, f); - await db.q('INSERT INTO lead_marks (lead,sponsor,contacted_ts,warned_ts) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE sponsor=VALUES(sponsor), contacted_ts=VALUES(contacted_ts), warned_ts=VALUES(warned_ts)', [lead, m.sponsor || null, m.contacted || null, m.warned || null]); + await db.q('INSERT INTO lead_marks (`lead`,sponsor,contacted_ts,warned_ts) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE sponsor=VALUES(sponsor), contacted_ts=VALUES(contacted_ts), warned_ts=VALUES(warned_ts)', [lead, m.sponsor || null, m.contacted || null, m.warned || null]); } }; const rowA = r => ({ id: r.id, adoptee: r.adoptee, adopter: r.adopter, ts: Number(r.ts), expires: Number(r.expires), status: r.status, note: r.note || null, closed: r.closed ? Number(r.closed) : null });