mirror of
https://github.com/renee-png/acmcc.git
synced 2026-06-21 09:50:01 +00:00
183fe0a93c
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
25 lines
1005 B
SQL
25 lines
1005 B
SQL
|
|
-- Create avatars storage bucket
|
|
INSERT INTO storage.buckets (id, name, public) VALUES ('avatars', 'avatars', true)
|
|
ON CONFLICT (id) DO NOTHING;
|
|
|
|
-- Allow authenticated users to upload their own avatar
|
|
CREATE POLICY "Users can upload own avatar"
|
|
ON storage.objects FOR INSERT TO authenticated
|
|
WITH CHECK (bucket_id = 'avatars' AND (storage.foldername(name))[1] = auth.uid()::text);
|
|
|
|
-- Allow authenticated users to update their own avatar
|
|
CREATE POLICY "Users can update own avatar"
|
|
ON storage.objects FOR UPDATE TO authenticated
|
|
USING (bucket_id = 'avatars' AND (storage.foldername(name))[1] = auth.uid()::text);
|
|
|
|
-- Allow authenticated users to delete their own avatar
|
|
CREATE POLICY "Users can delete own avatar"
|
|
ON storage.objects FOR DELETE TO authenticated
|
|
USING (bucket_id = 'avatars' AND (storage.foldername(name))[1] = auth.uid()::text);
|
|
|
|
-- Allow public read access to avatars
|
|
CREATE POLICY "Public read access for avatars"
|
|
ON storage.objects FOR SELECT TO public
|
|
USING (bucket_id = 'avatars');
|