numerus/deploy/quote_product_tax.sql

35 lines
809 B
PL/PgSQL

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