-- Deploy camper:home to pg -- requires: roles -- requires: schema_camper -- requires: company -- requires: user_profile begin; set search_path to camper, public; create table home ( company_id integer not null primary key references company, slogan text not null ); grant select on table home to guest; grant select on table home to employee; grant select, insert, update, delete on table home to admin; alter table home enable row level security; create policy guest_ok on home for select using (true) ; create policy insert_to_company on home for insert with check ( company_id in (select company_id from user_profile) ) ; create policy update_company on home for update using ( company_id in (select company_id from user_profile) ) ; create policy delete_from_company on home for delete using ( company_id in (select company_id from user_profile) ) ; commit;