-- -- cr_cleanup_cr_files_del_tr/0 -- create or replace function cr_cleanup_cr_files_del_tr( ) returns trigger as $$ DECLARE BEGIN insert into cr_files_to_delete select r.content as path, i.storage_area_key from cr_items i, cr_revisions r where i.item_id = r.item_id and r.revision_id = old.revision_id and i.storage_type = 'file' and r.content is not null; return old; END; $$ language plpgsql;