feat: CRM Clinicas SaaS - MVP completo
- Auth: Login/Register con creacion de clinica - Dashboard: KPIs reales, graficas recharts - Pacientes: CRUD completo con busqueda - Agenda: FullCalendar, drag-and-drop, vista recepcion - Expediente: Notas SOAP, signos vitales, CIE-10 - Facturacion: Facturas con IVA, campos CFDI SAT - Inventario: Productos, stock, movimientos, alertas - Configuracion: Clinica, equipo, catalogo servicios - Supabase self-hosted: 18 tablas con RLS multi-tenant - Docker + Nginx para produccion Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
22
supabase/migrations/008_registration_policies.sql
Normal file
22
supabase/migrations/008_registration_policies.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
-- Fix: Allow new users to create clinics and profiles during registration
|
||||
-- The original RLS policies required a clinic_id which doesn't exist yet at signup time
|
||||
|
||||
-- Allow any authenticated user to create a clinic (for registration flow)
|
||||
DO $$ BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM pg_policies WHERE policyname = 'Authenticated users can create clinics' AND tablename = 'clinics'
|
||||
) THEN
|
||||
CREATE POLICY "Authenticated users can create clinics" ON clinics
|
||||
FOR INSERT WITH CHECK (auth.uid() IS NOT NULL);
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- Allow users to insert their own profile row
|
||||
DO $$ BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM pg_policies WHERE policyname = 'Users can insert own profile' AND tablename = 'users'
|
||||
) THEN
|
||||
CREATE POLICY "Users can insert own profile" ON users
|
||||
FOR INSERT WITH CHECK (id = auth.uid());
|
||||
END IF;
|
||||
END $$;
|
||||
Reference in New Issue
Block a user