20 lines
1.5 KiB
SQL
20 lines
1.5 KiB
SQL
-- ════════════════════════════════════════════════════════════════
|
|
-- 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(11) 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';
|