-- Deploy numerus:payment_account_bank to pg -- requires: roles -- requires: schema_numerus -- requires: payment_account -- requires: extension_iban begin; set search_path to numerus, public; create table payment_account_bank ( payment_account_id integer primary key, payment_account_type text not null default 'bank' constraint payment_account_type_is_bank check (payment_account_type = 'bank'), iban iban not null, foreign key (payment_account_id, payment_account_type) references payment_account (payment_account_id, payment_account_type) ); grant select, insert, update, delete on table payment_account_bank to invoicer; grant select, insert, update, delete on table payment_account_bank to admin; alter table payment_account_bank enable row level security; create policy company_policy on payment_account_bank using ( exists( select 1 from payment_account where payment_account.payment_account_id = payment_account_bank.payment_account_id ) ); commit;