-- SQLite can't DROP COLUMN cleanly on older versions; rebuild the table.
CREATE TABLE photo_insights_backup AS
    SELECT id, library_id, rel_path, title, summary, generated_at, model_version,
           is_current, training_messages, approved
    FROM photo_insights;
DROP TABLE photo_insights;
CREATE TABLE photo_insights (
    id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    library_id INTEGER NOT NULL REFERENCES libraries(id),
    rel_path TEXT NOT NULL,
    title TEXT NOT NULL,
    summary TEXT NOT NULL,
    generated_at BIGINT NOT NULL,
    model_version TEXT NOT NULL,
    is_current BOOLEAN NOT NULL DEFAULT TRUE,
    training_messages TEXT,
    approved BOOLEAN
);
INSERT INTO photo_insights
    SELECT id, library_id, rel_path, title, summary, generated_at, model_version,
           is_current, training_messages, approved
    FROM photo_insights_backup;
DROP TABLE photo_insights_backup;
