fix: create starred index after column migration, not before
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 <noreply@anthropic.com>
This commit is contained in:
1 parent
d18c855571
commit
64f7906b22
1 file changed
+2
-2
+2
-2
@@ -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 (?, ?)');
|
||||
|
||||
Reference in new issue
Block a user