35 lines
844 B
MySQL
35 lines
844 B
MySQL
|
-- Deploy camper:payment_method to pg
|
||
|
-- requires: roles
|
||
|
-- requires: schema_camper
|
||
|
-- requires: user_profile
|
||
|
-- requires: company
|
||
|
|
||
|
begin;
|
||
|
|
||
|
set search_path to camper, public;
|
||
|
|
||
|
create table payment_method (
|
||
|
payment_method_id integer generated by default as identity primary key,
|
||
|
company_id integer not null references company,
|
||
|
name text not null constraint name_not_empty check(length(trim(name)) > 0),
|
||
|
instructions text not null
|
||
|
);
|
||
|
|
||
|
grant select, insert, update, delete on table payment_method to employee;
|
||
|
grant select, insert, update, delete on table payment_method to admin;
|
||
|
|
||
|
alter table payment_method enable row level security;
|
||
|
|
||
|
create policy company_policy
|
||
|
on payment_method
|
||
|
using (
|
||
|
exists(
|
||
|
select 1
|
||
|
from company_user
|
||
|
join user_profile using (user_id)
|
||
|
where company_user.company_id = payment_method.company_id
|
||
|
)
|
||
|
);
|
||
|
|
||
|
commit;
|