numerus/deploy/contact_iban.sql

32 lines
634 B
PL/PgSQL

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