Files
inq-roi-simulador-web/supabase/migrations/003_create_processes.sql
Marcos Benítez 11da15136d feat(sprint-4/etapa-2): migración persistencia proceso/grupos/settings a Supabase
- Scripts SQL 002-004: process_groups, processes, app_settings con RLS
- supabaseProcessRepo: save/getById/getAll/delete con mapeo camelCase↔snake_case
  y limpieza Dexie en delete (actividades/gateways/resources/simulations)
- supabaseGroupRepo: save/getAll/getById/delete; FK ON DELETE SET NULL en processes
- supabaseSettingsRepo: get/update sobre fila singleton
- Stores actualizados: library-store y process-store usan repos Supabase para procesos
  (actividades/gateways/recursos siguen en Dexie hasta Etapa 3-4)
- ImportPage y useReportData actualizados a supabaseProcessRepo
- userId inyectado internamente en repos via supabase.auth.getSession() — no se
  threadea por la call stack; stores mantienen interfaces sin cambios
- 561/561 tests verdes, build limpio

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-28 00:23:38 -03:00

27 lines
1.4 KiB
SQL

CREATE TABLE IF NOT EXISTS public.processes (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
name text NOT NULL,
client text NOT NULL DEFAULT '',
bpmn_xml text NOT NULL DEFAULT '',
currency text NOT NULL DEFAULT 'USD',
overhead_percentage numeric NOT NULL DEFAULT 0,
annual_frequency numeric NOT NULL DEFAULT 1000,
analysis_horizon_years numeric NOT NULL DEFAULT 3,
automation_investment numeric NOT NULL DEFAULT 0,
group_id uuid REFERENCES public.process_groups(id) ON DELETE SET NULL,
tags text[] NOT NULL DEFAULT '{}',
owner_id uuid NOT NULL REFERENCES public.users(id),
created_by uuid NOT NULL REFERENCES public.users(id),
updated_by uuid NOT NULL REFERENCES public.users(id),
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now()
);
ALTER TABLE public.processes ENABLE ROW LEVEL SECURITY;
-- En Sprint 4 todos los usuarios son platform_admin: ven todo.
-- Las políticas granulares (process_access) se agregan en Etapa 5.
CREATE POLICY "authenticated_all_processes" ON public.processes
FOR ALL USING (auth.uid() IS NOT NULL)
WITH CHECK (auth.uid() IS NOT NULL);