-- =============================================================
-- LIS 03 — Perfiles de examen (paquetes)
-- Crea: lab_perfiles, lab_perfil_examenes
-- Depende de: exam_tipos (migración 003)
-- =============================================================

CREATE TABLE IF NOT EXISTS lab_perfiles (
    id      INT UNSIGNED    NOT NULL AUTO_INCREMENT,
    nombre  VARCHAR(150)    NOT NULL,
    activo  TINYINT(1)      NOT NULL DEFAULT 1,
    PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
  COMMENT='Paquetes de exámenes — replica PERFIL Firebird';

-- -----------------------------------------------------------

CREATE TABLE IF NOT EXISTS lab_perfil_examenes (
    perfil_id       INT UNSIGNED    NOT NULL,
    exam_tipo_id    INT UNSIGNED    NOT NULL,
    PRIMARY KEY (perfil_id, exam_tipo_id),
    CONSTRAINT fk_pe_perfil FOREIGN KEY (perfil_id)
        REFERENCES lab_perfiles (id) ON DELETE CASCADE,
    CONSTRAINT fk_pe_exam   FOREIGN KEY (exam_tipo_id)
        REFERENCES exam_tipos (id)   ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
  COMMENT='Exámenes por perfil — replica PERFIL_EXA Firebird';
