numerus/deploy/expense_attachment.sql

32 lines
702 B
MySQL
Raw Normal View History

-- Deploy numerus:expense_attachment to pg
-- requires: schema_numerus
-- requires: expense
begin;
set search_path to numerus, public;
create table expense_attachment (
expense_id integer not null primary key references expense,
original_filename text not null,
mime_type text not null,
content bytea not null
);
grant select, insert, update, delete on table expense_attachment to invoicer;
grant select, insert, update, delete on table expense_attachment to admin;
alter table expense_attachment enable row level security;
create policy company_policy
on expense_attachment
using (
exists(
select 1
from expense
where expense.expense_id = expense_attachment.expense_id
)
);
commit;