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