33 lines
754 B
PL/PgSQL
33 lines
754 B
PL/PgSQL
-- Deploy numerus:collection_attachment to pg
|
|
-- requires: roles
|
|
-- requires: schema_numerus
|
|
-- requires: collection
|
|
|
|
begin;
|
|
|
|
set search_path to numerus, public;
|
|
|
|
create table collection_attachment (
|
|
collection_id integer primary key references collection,
|
|
original_filename text not null,
|
|
mime_type text not null,
|
|
content bytea not null
|
|
);
|
|
|
|
grant select, insert, update, delete on table collection_attachment to invoicer;
|
|
grant select, insert, update, delete on table collection_attachment to admin;
|
|
|
|
alter table collection_attachment enable row level security;
|
|
|
|
create policy company_policy
|
|
on collection_attachment
|
|
using (
|
|
exists(
|
|
select 1
|
|
from collection
|
|
where collection.collection_id = collection_attachment.collection_id
|
|
)
|
|
);
|
|
|
|
commit;
|