This commit is contained in:
Lizandro Guarnizo
2026-04-22 09:03:43 -05:00
parent 4b8b668774
commit 076fae7857
5 changed files with 176 additions and 16 deletions
@@ -0,0 +1,19 @@
-- ════════════════════════════════════════════════════════════════
-- Migration 20260422 — Consentimientos por lugar/servicio del turnero
-- Permite asociar formularios de consentimiento directamente a un lugar
-- (p.ej. "Toma de Muestras 2") independientemente de los exámenes.
-- ════════════════════════════════════════════════════════════════
CREATE TABLE IF NOT EXISTS turnero_lugar_consentimientos (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
lugar_id INT UNSIGNED NOT NULL COMMENT 'FK turnero_lugares.id',
formulario_id INT UNSIGNED NOT NULL COMMENT 'FK lab_formularios.id',
creado_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id),
UNIQUE KEY uq_lugar_form (lugar_id, formulario_id),
INDEX idx_lugar (lugar_id),
INDEX idx_form (formulario_id),
CONSTRAINT fk_tlc_lugar FOREIGN KEY (lugar_id) REFERENCES turnero_lugares (id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT fk_tlc_form FOREIGN KEY (formulario_id) REFERENCES lab_formularios (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
COMMENT='Formularios de consentimiento que aplican para todo turno en un lugar/servicio dado';