Works exactly the same as for expenses, and this is sometimes convenient for keeping transfer slips from customers and such. I actually did not know where to add the download from this attachment, because if add a column to the index it can easily be confused with the download icon for the actual invoice. Part of #66.
33 lines
712 B
PL/PgSQL
33 lines
712 B
PL/PgSQL
-- Deploy numerus:invoice_attachment to pg
|
|
-- requires: schema_numerus
|
|
-- requires: roles
|
|
-- requires: invoice
|
|
|
|
begin;
|
|
|
|
set search_path to numerus, public;
|
|
|
|
create table invoice_attachment (
|
|
invoice_id integer primary key references invoice,
|
|
original_filename text not null,
|
|
mime_type text not null,
|
|
content bytea not null
|
|
);
|
|
|
|
grant select, insert, update, delete on table invoice_attachment to invoicer;
|
|
grant select, insert, update, delete on table invoice_attachment to admin;
|
|
|
|
alter table invoice_attachment enable row level security;
|
|
|
|
create policy company_policy
|
|
on invoice_attachment
|
|
using (
|
|
exists(
|
|
select 1
|
|
from invoice
|
|
where invoice.invoice_id = invoice_attachment.invoice_id
|
|
)
|
|
);
|
|
|
|
commit;
|