31 lines
646 B
PL/PgSQL
31 lines
646 B
PL/PgSQL
-- Deploy camper:contact_phone to pg
|
|
-- requires: roles
|
|
-- requires: schema_camper
|
|
-- requires: extension_pg_libphonenumber
|
|
|
|
begin;
|
|
|
|
set search_path to camper, public;
|
|
|
|
create table contact_phone (
|
|
contact_id integer primary key references contact,
|
|
phone packed_phone_number not null
|
|
);
|
|
|
|
grant select, insert, update, delete on table contact_phone to employee;
|
|
grant select, insert, update, delete on table contact_phone to admin;
|
|
|
|
alter table contact_phone enable row level security;
|
|
|
|
create policy company_policy
|
|
on contact_phone
|
|
using (
|
|
exists(
|
|
select 1
|
|
from contact
|
|
where contact.contact_id = contact_phone.contact_id
|
|
)
|
|
);
|
|
|
|
commit;
|