numerus/deploy/contact_tag.sql

32 lines
649 B
PL/PgSQL

-- Deploy numerus:contact_tag to pg
-- requires: schema_numerus
-- requires: tag
-- requires: contact
begin;
set search_path to numerus, public;
create table contact_tag (
contact_id integer not null references contact,
tag_id integer not null references tag,
primary key (contact_id, tag_id)
);
grant select, insert, update, delete on table contact_tag to invoicer;
grant select, insert, update, delete on table contact_tag to admin;
alter table contact_tag enable row level security;
create policy company_policy
on contact_tag
using (
exists(
select 1
from contact
where contact.contact_id = contact_tag.contact_id
)
);
commit;