Can no longer update library database with sqlite3

In DB Browser, delete the two triggers, and write (commit) the change:
fts4_metadata_titles_before_update_icu
fts4_metadata_titles_after_update_icu

Run your metadata update SQL statements. For example, to chronologically reorder:
UPDATE metadata_items
SET added_at = originally_available_at
WHERE library_section_id = 25;

Then recreate the two triggers, then commit:

CREATE TRIGGER fts4_metadata_titles_before_update_icu BEFORE UPDATE ON metadata_items BEGIN DELETE FROM fts4_metadata_titles_icu WHERE docid=old.rowid; END

CREATE TRIGGER fts4_metadata_titles_after_update_icu AFTER UPDATE ON metadata_items BEGIN INSERT INTO fts4_metadata_titles_icu(docid, title, title_sort, original_title) VALUES(new.rowid, new.title, new.title_sort, new.original_title); END

As always, as a precaution, shut down Plex, and make a copy of your DB first before making edits. I have no idea what would happen if Plex started updating libraries after you delete your triggers, but probably nothing good. :slight_smile:

Also noticed that, for those who use UpdateTool for IMDB ratings, the code was recently fixed to do exactly the same thing with those triggers.

7 Likes