set role "speaker-to-postgres";
create trigger title_insert
       before insert on title for each row execute procedure insert_row_created_with();
create trigger title_update
       before update on title for each row execute procedure update_row_modified();
create trigger title_log
       before insert or update or delete on title for each row execute procedure log_row();
create trigger entity_insert
       before insert on entity for each row execute procedure insert_row_created_with();
create trigger entity_update
       before update on entity for each row execute procedure update_row_modified();
create trigger entity_log
       before insert or update or delete on entity for each row execute procedure log_row();
create trigger title_responsibility_update 
       before insert or update or delete on title_responsibility
       for each row execute procedure collateral_update('title');
create trigger title_responsibility_log
       before insert or update or delete on title_responsibility
       for each row execute procedure log_row('title_id');
create trigger title_title_update 
       before insert or update or delete on title_title
       for each row execute procedure collateral_update('title');
create trigger title_title_log
       before insert or update or delete on title_title
       for each row execute procedure log_row('title_id');
create trigger series_insert
       before insert on series for each row execute procedure insert_row_created_with();
create trigger series_update
       before update on series for each row execute procedure update_row_modified();
create trigger series_log
       before insert or update or delete on series for each row execute procedure log_row();
create trigger title_series_update 
       before insert or update or delete on title_series
       for each row execute procedure collateral_update('title');
create trigger title_series_log
       before insert or update or delete on title_series
       for each row execute procedure log_row('title_id');
create trigger book_insert
       before insert on book for each row execute procedure insert_row_created_with();
create trigger book_update
       before update on book for each row execute procedure update_row_modified();
create trigger book_log
       before insert or update or delete on book for each row execute procedure log_row();
-- create trigger book_collateral
--       before insert or update or delete on book
--       for each row execute procedure collateral_update('title');
create trigger barcode_insert
       before insert on barcode
       for each row execute procedure insert_row_created_with();
create trigger barcode_update
       before update on barcode
       for each row execute procedure update_row_modified();
create trigger barcode_log
       before insert or update or delete on barcode
       for each row execute procedure log_row('book_id');
reset role;
