40 lines
727 B
PL/PgSQL
40 lines
727 B
PL/PgSQL
-- Deploy numerus:contact_web to pg
|
|
-- requires: roles
|
|
-- requires: schema_numerus
|
|
-- requires: extension_uri
|
|
-- requires: contact
|
|
|
|
begin;
|
|
|
|
set search_path to numerus, public;
|
|
|
|
create table contact_web (
|
|
contact_id integer primary key references contact,
|
|
uri uri not null
|
|
);
|
|
|
|
grant select, insert, update, delete on table contact_web to invoicer;
|
|
grant select, insert, update, delete on table contact_web to admin;
|
|
|
|
alter table contact_web enable row level security;
|
|
|
|
create policy company_policy
|
|
on contact_web
|
|
using (
|
|
exists(
|
|
select 1
|
|
from contact
|
|
where contact.contact_id = contact_web.contact_id
|
|
)
|
|
);
|
|
|
|
insert into contact_web
|
|
select contact_id, web
|
|
from contact;
|
|
|
|
alter table contact
|
|
drop column web
|
|
;
|
|
|
|
commit;
|