-- REQUIREMENTS ACHIVEMENT CHECK
SELECT slug, 
  hash, 
  library_section_id,
  refreshed_at, 
  added_at, 
  created_at, 
  updated_at, 
  changed_at, 
  resources_changed_at
from metadata_items
WHERE slug IN ('alien', 'spartacus', 'halloween', 'fatale', 'cube', 'alcarras', 'atlas', 'damsel')
order by slug;


--23 CINE Asia
  --39 CINE Eslavo
  --28 CINE Latino
  --38 CINE Muslim


--action

drop trigger fts4_metadata_titles_after_update_icu;

drop trigger fts4_metadata_titles_before_update_icu;

-- update 
UPDATE metadata_items AS DESTINATION
SET refreshed_at = ORIGIN.refreshed_at,
    added_at = ORIGIN.added_at,
    created_at = ORIGIN.created_at,
    updated_at = ORIGIN.updated_at,
    changed_at = ORIGIN.changed_at,
    resources_changed_at = ORIGIN.resources_changed_at
FROM metadata_items AS ORIGIN
WHERE DESTINATION.library_section_id = 23
AND ORIGIN.library_section_id = 39
AND DESTINATION.hash = ORIGIN.hash;


--triggers restore
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;
