debats/supabase/migrations/20260212000000_rename_user_profiles_to_contributors.sql
Jalil Arfaoui ebf0b38b0b feat: authentification Supabase, entité Contributor, inscription par URL secrète
- Middleware SSR pour rafraîchir les sessions auth
- Route callback /api/auth/callback (échange code PKCE + création contributor)
- LoginModal branché sur signInWithPassword
- SignupModal + page /inscription/[token] protégée par SIGNUP_SECRET_TOKEN
- AuthSection : écoute onAuthStateChange, affiche nom + déconnexion
- Entité domaine Contributor (id, reputation) avec tests TDD
- Migration : rename user_profiles → contributors, suppression colonne name
- Tests colocated avec le code (plus de dossier __tests__/)
- Composant SwitchLink extrait dans components/ui
2026-02-12 01:59:47 +01:00

31 lines
1.1 KiB
SQL

-- Rename user_profiles to contributors and drop redundant name column
-- Drop existing policies
DROP POLICY IF EXISTS "Users read own profile" ON user_profiles;
DROP POLICY IF EXISTS "Users update own profile" ON user_profiles;
-- Drop existing trigger
DROP TRIGGER IF EXISTS update_user_profiles_updated_at ON user_profiles;
-- Rename the table
ALTER TABLE user_profiles RENAME TO contributors;
-- Drop name column (redundant with auth.users.raw_user_meta_data)
ALTER TABLE contributors DROP COLUMN name;
-- Recreate trigger with new name
CREATE TRIGGER update_contributors_updated_at
BEFORE UPDATE ON contributors
FOR EACH ROW EXECUTE FUNCTION update_updated_at_column();
-- Recreate RLS policies
CREATE POLICY "Contributors read own profile" ON contributors
FOR SELECT USING (auth.uid() = id);
CREATE POLICY "Contributors update own profile" ON contributors
FOR UPDATE USING (auth.uid() = id);
-- Allow inserting own profile (needed for signup)
CREATE POLICY "Contributors insert own profile" ON contributors
FOR INSERT TO authenticated
WITH CHECK (auth.uid() = id);