-- Deploy camper:media_path to pg
-- requires: roles
-- requires: schema_camper
-- requires: media

begin;

set search_path to camper, public;

create or replace function path(media) returns text as
$$
	select '/media/' || encode($1.hash, 'hex') || '/' || $1.original_filename;
$$
	language sql
	stable
;

revoke execute on function path(media) from public;
grant execute on function path(media) to guest;
grant execute on function path(media) to employee;
grant execute on function path(media) to admin;

commit;
