MIGRATION VERS GITEA
This commit is contained in:
commit
5f9d991c15
333 files changed
+108514
No files matched your search
@@ -0,0 +1,80 @@
|
||||
-- ============================================================================
|
||||
-- CORRECTIF : Policies RLS du bucket "banque-annonces" et des tables SQL
|
||||
-- Date : 2026-07-02
|
||||
--
|
||||
-- Problème : L'application utilise la clé anon et une authentification custom. Les
|
||||
-- policies de banque_mots et de storage.objects qui exigent un utilisateur
|
||||
-- authentifié (TO authenticated) bloquent l'INSERT/UPDATE/DELETE et provoquent
|
||||
-- l'erreur "new row violates row-level security policy".
|
||||
--
|
||||
-- Solution : Recréer des policies pour permettre SELECT, INSERT, UPDATE, DELETE
|
||||
-- sur le bucket 'banque-annonces' et sur les tables de la base de données.
|
||||
--
|
||||
-- ⚠️ À EXÉCUTER dans l'éditeur SQL Supabase :
|
||||
-- https://app.supabase.com → votre projet → SQL Editor
|
||||
-- ============================================================================
|
||||
|
||||
-- 1. Réglage des politiques RLS pour les tables de base de données
|
||||
-- ============================================================================
|
||||
|
||||
-- Table: banque_mots
|
||||
DROP POLICY IF EXISTS "Authenticated users can read banque_mots" ON public.banque_mots;
|
||||
DROP POLICY IF EXISTS "Authenticated users can insert banque_mots" ON public.banque_mots;
|
||||
DROP POLICY IF EXISTS "Authenticated users can update banque_mots" ON public.banque_mots;
|
||||
|
||||
CREATE POLICY "Public read banque_mots" ON public.banque_mots FOR SELECT USING (deleted_at IS NULL);
|
||||
CREATE POLICY "Public insert banque_mots" ON public.banque_mots FOR INSERT WITH CHECK (true);
|
||||
CREATE POLICY "Public update banque_mots" ON public.banque_mots FOR UPDATE USING (true);
|
||||
CREATE POLICY "Public delete banque_mots" ON public.banque_mots FOR DELETE USING (true);
|
||||
|
||||
-- Table: annonces_templates
|
||||
DROP POLICY IF EXISTS "Authenticated users can read templates" ON public.annonces_templates;
|
||||
DROP POLICY IF EXISTS "Authenticated users can insert templates" ON public.annonces_templates;
|
||||
DROP POLICY IF EXISTS "Authenticated users can update templates" ON public.annonces_templates;
|
||||
|
||||
CREATE POLICY "Public read templates" ON public.annonces_templates FOR SELECT USING (deleted_at IS NULL);
|
||||
CREATE POLICY "Public insert templates" ON public.annonces_templates FOR INSERT WITH CHECK (true);
|
||||
CREATE POLICY "Public update templates" ON public.annonces_templates FOR UPDATE USING (true);
|
||||
CREATE POLICY "Public delete templates" ON public.annonces_templates FOR DELETE USING (true);
|
||||
|
||||
-- Table: annonces_enregistrees
|
||||
DROP POLICY IF EXISTS "Authenticated users can read annonces" ON public.annonces_enregistrees;
|
||||
DROP POLICY IF EXISTS "Authenticated users can insert annonces" ON public.annonces_enregistrees;
|
||||
DROP POLICY IF EXISTS "Authenticated users can update annonces" ON public.annonces_enregistrees;
|
||||
|
||||
CREATE POLICY "Public read annonces" ON public.annonces_enregistrees FOR SELECT USING (deleted_at IS NULL);
|
||||
CREATE POLICY "Public insert annonces" ON public.annonces_enregistrees FOR INSERT WITH CHECK (true);
|
||||
CREATE POLICY "Public update annonces" ON public.annonces_enregistrees FOR UPDATE USING (true);
|
||||
CREATE POLICY "Public delete annonces" ON public.annonces_enregistrees FOR DELETE USING (true);
|
||||
|
||||
|
||||
-- 2. Réglage des politiques RLS du Bucket Storage "banque-annonces"
|
||||
-- ============================================================================
|
||||
|
||||
-- Supprimer les anciennes politiques storage si elles existent
|
||||
DROP POLICY IF EXISTS "Public read access on banque-annonces" ON storage.objects;
|
||||
DROP POLICY IF EXISTS "Authenticated users can upload to banque-annonces" ON storage.objects;
|
||||
DROP POLICY IF EXISTS "Authenticated users can delete from banque-annonces" ON storage.objects;
|
||||
DROP POLICY IF EXISTS "Public upload access on banque-annonces" ON storage.objects;
|
||||
DROP POLICY IF EXISTS "Public update access on banque-annonces" ON storage.objects;
|
||||
DROP POLICY IF EXISTS "Public delete access on banque-annonces" ON storage.objects;
|
||||
|
||||
-- Lecture publique pour tous
|
||||
CREATE POLICY "Public read access on banque-annonces"
|
||||
ON storage.objects FOR SELECT
|
||||
USING (bucket_id = 'banque-annonces');
|
||||
|
||||
-- Insertion publique (Upload)
|
||||
CREATE POLICY "Public upload access on banque-annonces"
|
||||
ON storage.objects FOR INSERT
|
||||
WITH CHECK (bucket_id = 'banque-annonces');
|
||||
|
||||
-- Mise à jour publique (Upsert)
|
||||
CREATE POLICY "Public update access on banque-annonces"
|
||||
ON storage.objects FOR UPDATE
|
||||
USING (bucket_id = 'banque-annonces');
|
||||
|
||||
-- Suppression publique (Delete)
|
||||
CREATE POLICY "Public delete access on banque-annonces"
|
||||
ON storage.objects FOR DELETE
|
||||
USING (bucket_id = 'banque-annonces');
|
||||
Reference in new issue
Block a user