- 00-schema.sql: Schema creation with grants - 01-enums.sql: 8 enums (goal_type, metric_type, period_type, etc.) - 02-tables.sql: 4 tables (definitions, assignments, progress_log, milestone_notifications) - 04-rls.sql: 16 RLS policies for tenant isolation - 05-indexes.sql: Performance indexes Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
71 lines
1.7 KiB
SQL
71 lines
1.7 KiB
SQL
-- ============================================
|
|
-- SAAS-022: Goals Enums
|
|
-- ============================================
|
|
|
|
-- Tipo de meta
|
|
CREATE TYPE goals.goal_type AS ENUM (
|
|
'target', -- Alcanzar un objetivo
|
|
'limit', -- No exceder un limite
|
|
'maintain' -- Mantener un valor
|
|
);
|
|
|
|
-- Tipo de metrica
|
|
CREATE TYPE goals.metric_type AS ENUM (
|
|
'number', -- Numero entero
|
|
'currency', -- Monto monetario
|
|
'percentage', -- Porcentaje
|
|
'boolean', -- Si/No
|
|
'count' -- Conteo
|
|
);
|
|
|
|
-- Tipo de periodo
|
|
CREATE TYPE goals.period_type AS ENUM (
|
|
'daily',
|
|
'weekly',
|
|
'monthly',
|
|
'quarterly',
|
|
'yearly',
|
|
'custom'
|
|
);
|
|
|
|
-- Fuente de datos para tracking automatico
|
|
CREATE TYPE goals.data_source AS ENUM (
|
|
'manual', -- Actualizado manualmente
|
|
'sales', -- Desde modulo Sales
|
|
'billing', -- Desde modulo Billing
|
|
'commissions', -- Desde modulo Commissions
|
|
'custom' -- Fuente personalizada
|
|
);
|
|
|
|
-- Estado de la meta
|
|
CREATE TYPE goals.goal_status AS ENUM (
|
|
'draft', -- Borrador
|
|
'active', -- Activa
|
|
'paused', -- Pausada
|
|
'completed', -- Completada
|
|
'cancelled' -- Cancelada
|
|
);
|
|
|
|
-- Tipo de asignado
|
|
CREATE TYPE goals.assignee_type AS ENUM (
|
|
'user', -- Usuario individual
|
|
'team', -- Equipo
|
|
'tenant' -- Todo el tenant
|
|
);
|
|
|
|
-- Estado de asignacion
|
|
CREATE TYPE goals.assignment_status AS ENUM (
|
|
'active', -- En progreso
|
|
'achieved', -- Lograda
|
|
'failed', -- No alcanzada
|
|
'cancelled' -- Cancelada
|
|
);
|
|
|
|
-- Fuente del progreso
|
|
CREATE TYPE goals.progress_source AS ENUM (
|
|
'manual', -- Entrada manual
|
|
'automatic', -- Tracking automatico
|
|
'import', -- Importacion
|
|
'api' -- Via API externa
|
|
);
|