From 64f7906b22f205c7d5c3adf4e0aeeb748b413284 Mon Sep 17 00:00:00 2001 From: nmemmert <67961292+nmemmert@users.noreply.github.com> Date: Tue, 18 Aug 2026 08:11:14 -0400 Subject: [PATCH] fix: create starred index after column migration, not before MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CREATE INDEX on photos(starred) ran inside the main db.exec() block, which fires before the ALTER TABLE migration that adds the starred column. On databases created before the starred feature, this crashed the process on startup with "no such column: starred" — causing the worker container to exit silently with no logs. Move the index creation to after the migration so the column always exists. Co-Authored-By: Claude Sonnet 4.6 --- worker/db.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/worker/db.js b/worker/db.js index 275612e..8c47cb2 100644 --- a/worker/db.js +++ b/worker/db.js @@ -37,7 +37,6 @@ export function openDb(dbPath) { CREATE INDEX IF NOT EXISTS idx_photos_date_taken ON photos(date_taken); CREATE INDEX IF NOT EXISTS idx_photos_phash ON photos(phash); - CREATE INDEX IF NOT EXISTS idx_photos_starred ON photos(starred); CREATE TABLE IF NOT EXISTS collections ( id INTEGER PRIMARY KEY AUTOINCREMENT, @@ -95,8 +94,9 @@ export function openDb(dbPath) { ); `); - // Column migrations + // Column migrations — run before any indexes that depend on the new column try { db.exec('ALTER TABLE photos ADD COLUMN starred INTEGER NOT NULL DEFAULT 0'); } catch {} + db.exec('CREATE INDEX IF NOT EXISTS idx_photos_starred ON photos(starred)'); // Seed default settings const seedSetting = db.prepare('INSERT OR IGNORE INTO settings (key, value) VALUES (?, ?)');