numerus/verify/expense_attachment.sql
jordi fita mas 5d46bbb95b Add the relation to store the expense’s attachment files
It is a separate table because we allow expenses to not have such an
attachment, although we allow only an attachment per expense, and i do
not want to have a bunch of nullable columns for that.

I decided to keep the files in the database, contrary to “conventional
wisdom” of storing files in the filesystem, because these attachments
are invoices and such documets that are an integral part of the expense
relation.  In other words, losing these files would render the expense
(almost) useless.  Thus, the ACID guarantees of the database are the
most appropriate place for them.
2023-05-13 21:23:24 +02:00

16 lines
412 B
PL/PgSQL

-- Verify numerus:expense_attachment on pg
begin;
select expense_id
, original_filename
, mime_type
, content
from numerus.expense_attachment
where false;
select 1 / count(*) from pg_class where oid = 'numerus.expense_attachment'::regclass and relrowsecurity;
select 1 / count(*) from pg_policy where polname = 'company_policy' and polrelid = 'numerus.expense_attachment'::regclass;
rollback;