33 lines
745 B
PL/PgSQL
33 lines
745 B
PL/PgSQL
-- Deploy numerus:invoice_collection to pg
|
|
-- requires: roles
|
|
-- requires: schema_numerus
|
|
-- requires: invoice
|
|
-- requires: collection
|
|
|
|
begin;
|
|
|
|
set search_path to numerus, public;
|
|
|
|
create table invoice_collection (
|
|
invoice_id integer not null references invoice,
|
|
collection_id integer not null references collection,
|
|
primary key (invoice_id, collection_id)
|
|
);
|
|
|
|
grant select, insert, update, delete on table invoice_collection to invoicer;
|
|
grant select, insert, update, delete on table invoice_collection to admin;
|
|
|
|
alter table invoice_collection enable row level security;
|
|
|
|
create policy company_policy
|
|
on invoice_collection
|
|
using (
|
|
exists(
|
|
select 1
|
|
from invoice
|
|
where invoice.invoice_id = invoice_collection.invoice_id
|
|
)
|
|
);
|
|
|
|
commit;
|