35 lines
870 B
SQL
35 lines
870 B
SQL
alter table public.profiles
|
|
add column avatar_path text;
|
|
|
|
insert into storage.buckets(id, name, public, file_size_limit, allowed_mime_types)
|
|
values (
|
|
'minegeo-avatars',
|
|
'minegeo-avatars',
|
|
true,
|
|
5242880,
|
|
array['image/jpeg', 'image/png', 'image/webp']
|
|
)
|
|
on conflict (id) do update set
|
|
name = excluded.name,
|
|
public = excluded.public,
|
|
file_size_limit = excluded.file_size_limit,
|
|
allowed_mime_types = excluded.allowed_mime_types;
|
|
|
|
create policy "MineGeo users upload their own avatars"
|
|
on storage.objects
|
|
for insert
|
|
to authenticated
|
|
with check (
|
|
bucket_id = 'minegeo-avatars'
|
|
and (storage.foldername(name))[1] = (select auth.uid()::text)
|
|
);
|
|
|
|
create policy "MineGeo users delete their own avatars"
|
|
on storage.objects
|
|
for delete
|
|
to authenticated
|
|
using (
|
|
bucket_id = 'minegeo-avatars'
|
|
and (storage.foldername(name))[1] = (select auth.uid()::text)
|
|
);
|