--
-- content_search__utrg/0
--
create or replace function content_search__utrg(
  
) returns trigger as $$

declare
    v_live_revision integer;
begin
    select into v_live_revision live_revision from
        cr_items where item_id=old.item_id;
    if old.revision_id=v_live_revision
      and new.publish_date <= current_timestamp then
        insert into search_observer_queue (
            object_id,
            event
        ) values (
old.revision_id,
            'UPDATE'
        );
    end if;
    return new;
end;$$ language plpgsql;