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