34 lines
700 B
PL/PgSQL
34 lines
700 B
PL/PgSQL
-- Deploy numerus:expense_tax to pg
|
|
-- requires: schema_numerus
|
|
-- requires: expense
|
|
-- requires: tax
|
|
-- requires: tax_rate
|
|
|
|
begin;
|
|
|
|
set search_path to numerus, public;
|
|
|
|
create table expense_tax (
|
|
expense_id integer not null references expense,
|
|
tax_id integer not null references tax,
|
|
tax_rate tax_rate not null,
|
|
primary key (expense_id, tax_id)
|
|
);
|
|
|
|
grant select, insert, update, delete on table expense_tax to invoicer;
|
|
grant select, insert, update, delete on table expense_tax to admin;
|
|
|
|
alter table expense_tax enable row level security;
|
|
|
|
create policy company_policy
|
|
on expense_tax
|
|
using (
|
|
exists(
|
|
select 1
|
|
from expense
|
|
where expense.expense_id = expense_tax.expense_id
|
|
)
|
|
);
|
|
|
|
commit;
|