35 lines
834 B
MySQL
35 lines
834 B
MySQL
|
-- Deploy numerus:tax_class to pg
|
||
|
-- requires: schema_numerus
|
||
|
-- requires: company
|
||
|
|
||
|
begin;
|
||
|
|
||
|
set search_path to numerus, public;
|
||
|
|
||
|
create table tax_class (
|
||
|
tax_class_id serial not null primary key,
|
||
|
company_id integer not null references company,
|
||
|
name text not null constraint name_not_empty check(length(trim(name)) > 0)
|
||
|
);
|
||
|
|
||
|
grant select, insert, update, delete on table tax_class to invoicer;
|
||
|
grant select, insert, update, delete on table tax_class to admin;
|
||
|
|
||
|
grant usage on sequence tax_class_tax_class_id_seq to invoicer;
|
||
|
grant usage on sequence tax_class_tax_class_id_seq to admin;
|
||
|
|
||
|
alter table tax_class enable row level security;
|
||
|
|
||
|
create policy company_policy
|
||
|
on tax_class
|
||
|
using (
|
||
|
exists(
|
||
|
select 1
|
||
|
from company_user
|
||
|
join user_profile using (user_id)
|
||
|
where company_user.company_id = tax_class.company_id
|
||
|
)
|
||
|
);
|
||
|
|
||
|
commit;
|