-- Deploy numerus:invoice_payment to pg -- requires: roles -- requires: schema_numerus -- requires: invoice -- requires: payment begin; set search_path to numerus, public; create table invoice_payment ( invoice_id integer not null references invoice, payment_id integer not null references payment, primary key (invoice_id, payment_id) ); grant select, insert, update, delete on table invoice_payment to invoicer; grant select, insert, update, delete on table invoice_payment to admin; alter table invoice_payment enable row level security; create policy company_policy on invoice_payment using ( exists( select 1 from invoice where invoice.invoice_id = invoice_payment.invoice_id ) ); commit;