before_insert

Original query:

CREATE OR REPLACE FUNCTION prepare_full_text_search_document()
 RETURNS TRIGGER
 AS $$
 DECLARE
 new_document tsvector;
 BEGIN
   new_document :=
     to_tsvector('english', coalesce(NEW.role, '') || ' ' || coalesce(NEW.description, ''));
       
43    NEW.full_text_search := new_document;
  1   RETURN NEW;
  2 END;
  3 $$ LANGUAGE plpgsql;
  4 
  5 CREATE TRIGGER trg_prepare_document
  6 BEFORE INSERT OR UPDATE OF role, description ON job_posts
  7 FOR EACH ROW
  8 EXECUTE PROCEDURE prepare_full_text_search_document();