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.
16 lines
412 B
PL/PgSQL
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;
|