32 lines
646 B
PL/PgSQL
32 lines
646 B
PL/PgSQL
-- Deploy camper:product_tax to pg
|
|
-- requires: schema_camper
|
|
-- requires: product
|
|
-- requires: tax
|
|
|
|
begin;
|
|
|
|
set search_path to camper, public;
|
|
|
|
create table product_tax (
|
|
product_id integer not null references product,
|
|
tax_id integer not null references tax,
|
|
primary key (product_id, tax_id)
|
|
);
|
|
|
|
grant select, insert, update, delete on table product_tax to employee;
|
|
grant select, insert, update, delete on table product_tax to admin;
|
|
|
|
alter table product_tax enable row level security;
|
|
|
|
create policy company_policy
|
|
on product_tax
|
|
using (
|
|
exists(
|
|
select 1
|
|
from product
|
|
where product.product_id = product_tax.product_id
|
|
)
|
|
);
|
|
|
|
commit;
|