Fix startup crash on existing DB: move account_id indexes after migration

This commit is contained in:
2026-03-12 22:24:15 -06:00
parent e81a4386d2
commit c689ddc72a
2 changed files with 6 additions and 2 deletions
+6
View File
@@ -93,4 +93,10 @@ if (!lfInfo.some(c => c.name === 'account_id')) {
`); `);
} }
// Create account_id indexes unconditionally (safe after migrations have run)
db.exec(`
CREATE INDEX IF NOT EXISTS idx_checks_account ON checks(account_id);
CREATE INDEX IF NOT EXISTS idx_layout_account ON layout_fields(account_id);
`);
module.exports = db; module.exports = db;
-2
View File
@@ -71,5 +71,3 @@ CREATE TABLE IF NOT EXISTS layout_fields (
CREATE INDEX IF NOT EXISTS idx_checks_date ON checks(check_date); CREATE INDEX IF NOT EXISTS idx_checks_date ON checks(check_date);
CREATE INDEX IF NOT EXISTS idx_checks_printed ON checks(printed); CREATE INDEX IF NOT EXISTS idx_checks_printed ON checks(printed);
CREATE INDEX IF NOT EXISTS idx_checks_check_no ON checks(check_no); CREATE INDEX IF NOT EXISTS idx_checks_check_no ON checks(check_no);
CREATE INDEX IF NOT EXISTS idx_checks_account ON checks(account_id);
CREATE INDEX IF NOT EXISTS idx_layout_account ON layout_fields(account_id);