Especificación Técnica: cat_canales¶
Esquema: core.notificaciones
Base de Datos: core
Servicio: svc-notificaciones
Propósito: Catálogo global de canales de notificación (email, whatsapp, sms, push, etc.), reutilizable sin tenencia por empresa.
1. Justificación y Mejoras de Arquitectura¶
- Catálogo global y sin dependencia empresarial, como
cat_tipos_identificaciondecore.identidad; se comparte entre todas las empresas sin duplicar filas. - Se sustituye el canal implícito del legado
c038t_correopor un catálogo explícito y extensible. codigocon índice único parcial (WHERE deleted_at IS NULL) permite reutilizar un código tras el borrado lógico.- Tabla sin RLS por empresa por ser global.
2. Definiciones de Implementación¶
Table core.notificaciones.cat_canales {
id uuid [pk, default: `gen_random_uuid()`]
codigo text [not null]
nombre text [not null]
// Auditoría General
is_activo boolean [not null, default: `true`, note: 'Estado lógico del registro']
created_at timestamptz [not null, default: `now()`, note: 'Fecha de creación']
updated_at timestamptz [not null, default: `now()`, note: 'Fecha de última actualización']
deleted_at timestamptz [note: 'Fecha de eliminación lógica']
created_by uuid [note: 'Usuario creador']
updated_by uuid [note: 'Usuario modificador']
Indexes {
(codigo) [unique, name: 'uq_cat_canales_codigo', note: 'WHERE deleted_at IS NULL']
}
}
CREATE TABLE IF NOT EXISTS core.notificaciones.cat_canales (
id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,
codigo TEXT NOT NULL,
nombre TEXT NOT NULL,
-- Auditoría General
is_activo BOOLEAN NOT NULL DEFAULT true,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
deleted_at TIMESTAMPTZ,
created_by UUID,
updated_by UUID
);
CREATE UNIQUE INDEX IF NOT EXISTS uq_cat_canales_codigo ON core.notificaciones.cat_canales (codigo) WHERE deleted_at IS NULL;
-- Comentarios
COMMENT ON COLUMN core.notificaciones.cat_canales.codigo IS 'Código único del canal (email, whatsapp, sms, push, etc.)';
COMMENT ON COLUMN core.notificaciones.cat_canales.nombre IS 'Nombre descriptivo del canal';