-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Sep 12, 2026 at 09:02 PM
-- Server version: 10.4.32-MariaDB
-- PHP Version: 8.2.12

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `eqms`
--

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

--
-- Table structure for table `approval_delegations`
--

CREATE TABLE `approval_delegations` (
  `delegation_id` bigint(20) UNSIGNED NOT NULL,
  `from_user_id` bigint(20) UNSIGNED NOT NULL,
  `to_user_id` bigint(20) UNSIGNED NOT NULL,
  `workflow_id` bigint(20) UNSIGNED DEFAULT NULL,
  `start_date` date NOT NULL,
  `end_date` date DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `reason` text DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `assessment_questions`
--

CREATE TABLE `assessment_questions` (
  `question_id` bigint(20) UNSIGNED NOT NULL,
  `assessment_id` bigint(20) UNSIGNED DEFAULT NULL,
  `topic_id` bigint(20) UNSIGNED DEFAULT NULL,
  `question_text` text NOT NULL,
  `question_type` enum('multiple_choice','true_false','short_answer','essay','matching','fill_blank') NOT NULL DEFAULT 'multiple_choice',
  `question_category` enum('Knowledge','Comprehension','Application','Analysis','Synthesis','Evaluation') NOT NULL DEFAULT 'Knowledge',
  `difficulty_level` enum('Easy','Medium','Hard') NOT NULL DEFAULT 'Medium',
  `points` int(11) NOT NULL DEFAULT 1,
  `display_order` int(11) NOT NULL DEFAULT 0,
  `explanation` text DEFAULT NULL COMMENT 'Shown after answering',
  `reference` varchar(255) DEFAULT NULL COMMENT 'SOP / document reference',
  `correct_answer_text` text DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `audits`
--

CREATE TABLE `audits` (
  `audit_id` bigint(20) UNSIGNED NOT NULL,
  `audit_number` varchar(50) NOT NULL,
  `title` varchar(255) NOT NULL,
  `audit_type` varchar(50) NOT NULL,
  `audit_category` varchar(50) NOT NULL,
  `current_status` varchar(50) NOT NULL,
  `current_phase` varchar(50) NOT NULL,
  `priority` varchar(20) NOT NULL DEFAULT 'MEDIUM',
  `scope` text NOT NULL,
  `objectives` text DEFAULT NULL,
  `criteria` text DEFAULT NULL,
  `planned_start_date` date DEFAULT NULL,
  `planned_end_date` date DEFAULT NULL,
  `actual_start_date` date DEFAULT NULL,
  `actual_end_date` date DEFAULT NULL,
  `auditee_organisation` varchar(255) DEFAULT NULL,
  `lead_auditor_id` bigint(20) UNSIGNED DEFAULT NULL,
  `auditee_id` bigint(20) UNSIGNED DEFAULT NULL,
  `department_id` bigint(20) UNSIGNED DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `execution_summary` text DEFAULT NULL,
  `closing_meeting_notes` text DEFAULT NULL,
  `audit_report_summary` text DEFAULT NULL,
  `closure_summary` text DEFAULT NULL,
  `closed_date` date DEFAULT NULL,
  `is_major_nc_found` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `audits`
--

INSERT INTO `audits` (`audit_id`, `audit_number`, `title`, `audit_type`, `audit_category`, `current_status`, `current_phase`, `priority`, `scope`, `objectives`, `criteria`, `planned_start_date`, `planned_end_date`, `actual_start_date`, `actual_end_date`, `auditee_organisation`, `lead_auditor_id`, `auditee_id`, `department_id`, `created_by`, `execution_summary`, `closing_meeting_notes`, `audit_report_summary`, `closure_summary`, `closed_date`, `is_major_nc_found`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'AUD-2026-0001', 'Internal Audit — Production Department', 'INTERNAL', 'PROCESS', 'IN_PROGRESS', 'EXECUTION', 'HIGH', 'Batch manufacturing process for solid oral dosage forms including weighing, blending, compression, and coating. Reference: ISO 9001:2015 cl. 8.5.1 and internal SOPs MAN-PR-001 through MAN-PR-009.', 'Verify compliance with approved batch manufacturing procedures, assess equipment calibration status, and evaluate operator training records.', 'ISO 9001:2015 clause 8.5.1; internal SOP MAN-PR-001 to MAN-PR-009; GMP guidelines.', '2026-09-09', '2026-09-16', '2026-09-10', NULL, NULL, 1, NULL, 1, 1, NULL, NULL, NULL, NULL, NULL, 0, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(2, 'AUD-2026-0002', 'Supplier Audit — Primary Packaging Vendor', 'SUPPLIER', 'FACILITY', 'CLOSED', 'CLOSURE', 'MEDIUM', 'On-site assessment of the primary packaging supplier facility covering incoming materials, storage, production controls, quality systems, and traceability.', 'Evaluate supplier compliance with agreed quality specification and confirm capability to supply to current and forecast volume.', 'Supplier Quality Agreement SQA-2025-014; ISO 15378.', '2026-08-23', '2026-08-25', '2026-08-23', '2026-08-25', 'Acme Packaging Ltd', 1, NULL, NULL, 1, 'Two-day on-site audit conducted. Opening meeting held with supplier quality and operations leads. Reviewed documentation, interviewed staff, and observed production. Closing meeting held on day two — findings reviewed with the supplier.', 'Supplier acknowledged the findings and agreed to provide a written response within 14 days for all nonconformities.', NULL, NULL, '2026-09-12', 1, '2026-09-12 06:47:00', '2026-09-12 07:13:23', NULL),
(3, 'AUD-2026-0003', 'External Audit — Regulatory Inspection (GMP)', 'REGULATORY', 'SYSTEM', 'CLOSED', 'CLOSURE', 'CRITICAL', 'Routine GMP inspection covering quality management system, premises, equipment, documentation, production, quality control, and complaint handling.', 'Confirm ongoing compliance with GMP requirements and assess the effectiveness of the quality management system.', 'National GMP Guidelines; NDA inspection checklist.', '2026-07-14', '2026-07-17', '2026-07-14', '2026-07-17', 'National Drug Authority', 1, NULL, NULL, 1, 'Four-day regulatory inspection conducted. The inspection team reviewed documentation and toured the facility. Two minor observations were issued; no critical or major findings.', NULL, 'Two minor observations issued. No critical or major nonconformities identified. The inspection was closed without further action required.', 'Both minor observations addressed and CAPAs closed. Audit formally closed.', '2026-08-13', 0, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL);

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

--
-- Table structure for table `audit_audit_trails`
--

CREATE TABLE `audit_audit_trails` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `audit_id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `action_type` varchar(100) NOT NULL,
  `action_description` text DEFAULT NULL,
  `metadata` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`metadata`)),
  `changed_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `audit_audit_trails`
--

INSERT INTO `audit_audit_trails` (`id`, `audit_id`, `user_id`, `action_type`, `action_description`, `metadata`, `changed_at`) VALUES
(1, 1, 1, 'CREATED', 'Audit planned.', NULL, '2026-09-12 06:47:00'),
(2, 1, 1, 'STATUS_TRANSITION', 'Status changed from SCHEDULED to IN_PROGRESS.', '{\"from\":\"SCHEDULED\",\"to\":\"IN_PROGRESS\"}', '2026-09-10 05:00:00'),
(3, 2, 1, 'CREATED', 'Audit planned.', NULL, '2026-09-12 06:47:00'),
(4, 2, 1, 'STATUS_TRANSITION', 'Status changed from SCHEDULED to IN_PROGRESS.', '{\"from\":\"SCHEDULED\",\"to\":\"IN_PROGRESS\"}', '2026-08-23 05:00:00'),
(5, 2, 1, 'EXECUTION_UPDATED', 'Execution summary recorded.', NULL, '2026-09-14 06:47:00'),
(6, 3, 1, 'CREATED', 'Audit planned.', NULL, '2026-09-12 06:47:00'),
(7, 3, 1, 'STATUS_TRANSITION', 'Status changed from SCHEDULED to IN_PROGRESS.', '{\"from\":\"SCHEDULED\",\"to\":\"IN_PROGRESS\"}', '2026-07-14 05:00:00'),
(8, 3, 1, 'EXECUTION_UPDATED', 'Execution summary recorded.', NULL, '2026-09-14 06:47:00'),
(9, 3, 1, 'STATUS_TRANSITION', 'Status changed from REPORTING to CLOSED.', '{\"from\":\"REPORTING\",\"to\":\"CLOSED\"}', '2026-08-12 21:00:00'),
(10, 2, 1, 'STATUS_TRANSITION', 'Status changed from REPORTING to CLOSED. Reason: Approval required. Approver(s): QA Manager + Department Head + Qualified Person.', '{\"from\":\"REPORTING\",\"to\":\"CLOSED\",\"reason\":\"Approval required. Approver(s): QA Manager + Department Head + Qualified Person.\"}', '2026-09-12 07:13:23');

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

--
-- Table structure for table `audit_findings`
--

CREATE TABLE `audit_findings` (
  `finding_id` bigint(20) UNSIGNED NOT NULL,
  `audit_id` bigint(20) UNSIGNED NOT NULL,
  `finding_number` varchar(50) NOT NULL,
  `finding_type` varchar(50) NOT NULL,
  `severity` varchar(20) NOT NULL,
  `title` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `clause_reference` varchar(100) DEFAULT NULL,
  `area` varchar(255) DEFAULT NULL,
  `objective_evidence` text DEFAULT NULL,
  `auditee_response` text DEFAULT NULL,
  `response_due_date` date DEFAULT NULL,
  `response_received_date` date DEFAULT NULL,
  `capa_id` bigint(20) UNSIGNED DEFAULT NULL,
  `change_control_id` bigint(20) UNSIGNED DEFAULT NULL,
  `status` varchar(50) NOT NULL DEFAULT 'OPEN',
  `closed_date` date DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `audit_findings`
--

INSERT INTO `audit_findings` (`finding_id`, `audit_id`, `finding_number`, `finding_type`, `severity`, `title`, `description`, `clause_reference`, `area`, `objective_evidence`, `auditee_response`, `response_due_date`, `response_received_date`, `capa_id`, `change_control_id`, `status`, `closed_date`, `created_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 1, 'F-0001', 'MINOR_NC', 'MEDIUM', 'Batch record not signed by second operator', 'Batch record for lot BT-2026-0450 was not signed by the second operator at the blending step. Review of the prior 20 records shows this is an isolated occurrence.', 'ISO 9001:2015 cl. 8.5.1', 'Blending — Line 2', 'Copy of batch record for BT-2026-0450 (page 4, blending step); copy of SOP MAN-PR-004 requiring dual sign-off.', NULL, '2026-09-22', NULL, NULL, NULL, 'OPEN', NULL, 1, '2026-09-12 07:06:51', '2026-09-12 07:06:51', NULL),
(2, 1, 'F-0002', 'OBSERVATION', 'LOW', 'Calibration sticker on balance #3 faded', 'Calibration sticker on balance #3 in the weighing room was faded and partially illegible. Calibration log confirmed the balance is within calibration — only the sticker needed replacement.', 'ISO 9001:2015 cl. 7.1.5', 'Weighing Room', 'Photograph of the faded sticker; calibration log entry 2026-08-15.', 'Replacement sticker printed and applied on the same day. Photographic evidence attached.', '2026-09-17', '2026-09-11', NULL, NULL, 'IN_PROGRESS', NULL, 1, '2026-09-12 07:06:51', '2026-09-12 07:06:51', NULL),
(3, 2, 'F-0001', 'MAJOR_NC', 'HIGH', 'Incoming material inspection records incomplete', 'Incoming material inspection records for three of the ten sampled lots were missing the signature of the QC approver. Without this signature the material cannot be considered formally released.', 'ISO 15378 cl. 8.4.2', 'Incoming Goods — Inspection', 'Sample of 10 material inspection records; 3 identified without QC signature (lots AC-2026-0412, AC-2026-0418, AC-2026-0423).', NULL, '2026-09-26', NULL, 1, NULL, 'OPEN', NULL, 1, '2026-09-12 07:06:51', '2026-09-12 07:06:51', NULL),
(4, 2, 'F-0002', 'MINOR_NC', 'MEDIUM', 'Training records for packaging operators out of date', 'Two of five sampled packaging operators had training records that lapsed more than 30 days ago and had not been renewed.', 'ISO 15378 cl. 7.2', 'Packaging — Line 1', 'Training matrix extract showing lapsed dates for operators OP-114 and OP-121.', NULL, '2026-09-26', NULL, NULL, NULL, 'OPEN', NULL, 1, '2026-09-12 07:06:51', '2026-09-12 07:06:51', NULL),
(5, 2, 'F-0003', 'OPPORTUNITY', 'LOW', 'Consider barcode scanning at goods receipt', 'The supplier currently logs incoming materials manually. Barcode scanning at receipt would reduce transcription errors and speed up put-away. Not a compliance issue — an improvement opportunity.', NULL, 'Incoming Goods', NULL, NULL, NULL, NULL, NULL, NULL, 'ACCEPTED', NULL, 1, '2026-09-12 07:06:51', '2026-09-12 07:06:51', NULL),
(6, 3, 'F-0001', 'MINOR_NC', 'MEDIUM', 'SOP revision control not consistently applied', 'Two SOPs reviewed at the inspection were found to reference an obsolete version of a related document. The SOPs themselves are current, but the cross-references were not updated when the related document was revised.', 'GMP Chapter 4', 'Document Control', 'Copy of SOP QC-AN-012 referencing QC-AN-008 v3 when v4 is current.', 'Cross-references corrected in both SOPs. Additional review performed across all SOPs to identify similar issues. Two further cross-reference updates made.', '2026-07-29', '2026-07-26', NULL, NULL, 'CLOSED', '2026-08-08', 1, '2026-09-12 07:06:51', '2026-09-12 07:06:51', NULL),
(7, 3, 'F-0002', 'MINOR_NC', 'LOW', 'Pest control log gap', 'The pest control log showed a 5-day gap in January where no inspection was recorded, contrary to the monthly inspection schedule. No pest activity was observed during the gap.', 'GMP Chapter 3', 'Facility — Warehouse', 'Pest control log entry for January 2026 showing no inspection between 8th and 13th.', 'Gap investigated — pest control contractor had rescheduled the visit due to staff illness but failed to inform QA. Contractor SLAs updated to require 48-hour notification of any scheduling change.', '2026-07-29', '2026-07-27', NULL, NULL, 'CLOSED', '2026-08-08', 1, '2026-09-12 07:06:51', '2026-09-12 07:06:51', NULL);

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

--
-- Table structure for table `audit_links`
--

CREATE TABLE `audit_links` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `audit_id` bigint(20) UNSIGNED NOT NULL,
  `linked_type` varchar(100) NOT NULL,
  `linked_id` bigint(20) UNSIGNED NOT NULL,
  `relationship` varchar(50) NOT NULL,
  `impact_notes` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `audit_links`
--

INSERT INTO `audit_links` (`id`, `audit_id`, `linked_type`, `linked_id`, `relationship`, `impact_notes`, `created_at`, `updated_at`) VALUES
(1, 2, 'CAPA', 1, 'TRIGGERED', 'Triggered by finding F-0001 — incoming material inspection records incomplete.', '2026-09-12 07:06:51', '2026-09-12 07:06:51');

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

--
-- Table structure for table `audit_trails`
--

CREATE TABLE `audit_trails` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `action` varchar(255) NOT NULL,
  `model_type` varchar(255) NOT NULL,
  `model_id` bigint(20) UNSIGNED NOT NULL,
  `old_values` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`old_values`)),
  `new_values` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`new_values`)),
  `ip_address` varchar(255) DEFAULT NULL,
  `user_agent` text DEFAULT NULL,
  `status` varchar(255) DEFAULT 'success',
  `error_message` text DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `audit_trails`
--

INSERT INTO `audit_trails` (`id`, `user_id`, `action`, `model_type`, `model_id`, `old_values`, `new_values`, `ip_address`, `user_agent`, `status`, `error_message`, `created_by`, `updated_by`, `deleted_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 5, 'deleted', 'App\\Models\\Document', 4, NULL, NULL, '192.168.1.72', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'success', NULL, NULL, NULL, NULL, '2026-09-01 06:46:59', '2026-09-12 06:46:59', NULL),
(2, 1, 'created', 'App\\Models\\Company', 4, NULL, NULL, '192.168.1.21', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'success', NULL, NULL, NULL, NULL, '2026-08-27 06:46:59', '2026-09-12 06:46:59', NULL),
(3, 3, 'viewed', 'App\\Models\\User', 9, NULL, NULL, '192.168.1.242', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'success', NULL, NULL, NULL, NULL, '2026-08-26 06:46:59', '2026-09-12 06:46:59', NULL),
(4, 3, 'login', 'App\\Models\\Document', 5, NULL, NULL, '192.168.1.200', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'success', NULL, NULL, NULL, NULL, '2026-09-03 06:46:59', '2026-09-12 06:46:59', NULL),
(5, 1, 'login', 'App\\Models\\Company', 10, NULL, NULL, '192.168.1.78', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'success', NULL, NULL, NULL, NULL, '2026-08-24 06:46:59', '2026-09-12 06:46:59', NULL),
(6, 4, 'created', 'App\\Models\\Employee', 4, NULL, NULL, '192.168.1.54', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'success', NULL, NULL, NULL, NULL, '2026-09-11 06:46:59', '2026-09-12 06:46:59', NULL),
(7, 3, 'updated', 'App\\Models\\User', 1, NULL, NULL, '192.168.1.174', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'success', NULL, NULL, NULL, NULL, '2026-08-18 06:46:59', '2026-09-12 06:46:59', NULL),
(8, 3, 'logout', 'App\\Models\\Document', 2, NULL, NULL, '192.168.1.169', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'success', NULL, NULL, NULL, NULL, '2026-08-26 06:46:59', '2026-09-12 06:46:59', NULL),
(9, 2, 'deleted', 'App\\Models\\Company', 2, NULL, NULL, '192.168.1.202', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'success', NULL, NULL, NULL, NULL, '2026-08-18 06:46:59', '2026-09-12 06:46:59', NULL),
(10, 1, 'login', 'App\\Models\\Company', 6, NULL, NULL, '192.168.1.199', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'success', NULL, NULL, NULL, NULL, '2026-08-17 06:46:59', '2026-09-12 06:46:59', NULL),
(11, 4, 'created', 'App\\Models\\Company', 1, NULL, NULL, '192.168.1.72', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'success', NULL, NULL, NULL, NULL, '2026-08-31 06:46:59', '2026-09-12 06:46:59', NULL),
(12, 5, 'deleted', 'App\\Models\\Company', 7, NULL, NULL, '192.168.1.70', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'success', NULL, NULL, NULL, NULL, '2026-09-05 06:46:59', '2026-09-12 06:46:59', NULL),
(13, 5, 'created', 'App\\Models\\User', 3, NULL, NULL, '192.168.1.59', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'success', NULL, NULL, NULL, NULL, '2026-09-07 06:46:59', '2026-09-12 06:46:59', NULL),
(14, 4, 'logout', 'App\\Models\\Document', 6, NULL, NULL, '192.168.1.214', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'success', NULL, NULL, NULL, NULL, '2026-08-13 06:46:59', '2026-09-12 06:46:59', NULL),
(15, 2, 'deleted', 'App\\Models\\Employee', 8, NULL, NULL, '192.168.1.101', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'success', NULL, NULL, NULL, NULL, '2026-09-06 06:46:59', '2026-09-12 06:46:59', NULL),
(16, 3, 'logout', 'App\\Models\\User', 7, NULL, NULL, '192.168.1.155', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'success', NULL, NULL, NULL, NULL, '2026-08-13 06:46:59', '2026-09-12 06:46:59', NULL),
(17, 3, 'updated', 'App\\Models\\Employee', 8, NULL, NULL, '192.168.1.176', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'success', NULL, NULL, NULL, NULL, '2026-08-15 06:46:59', '2026-09-12 06:46:59', NULL),
(18, 5, 'login', 'App\\Models\\Employee', 1, NULL, NULL, '192.168.1.97', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'success', NULL, NULL, NULL, NULL, '2026-08-26 06:46:59', '2026-09-12 06:46:59', NULL),
(19, 1, 'updated', 'App\\Models\\Company', 2, NULL, NULL, '192.168.1.156', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'success', NULL, NULL, NULL, NULL, '2026-08-14 06:46:59', '2026-09-12 06:46:59', NULL),
(20, 2, 'updated', 'App\\Models\\Company', 7, NULL, NULL, '192.168.1.168', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'success', NULL, NULL, NULL, NULL, '2026-09-01 06:46:59', '2026-09-12 06:46:59', NULL),
(21, 1, 'login', 'App\\Models\\User', 1, NULL, NULL, '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.0.0.0 Safari/537.36', 'success', NULL, NULL, NULL, NULL, '2026-09-12 07:08:08', '2026-09-12 07:08:08', NULL),
(22, 1, 'login', 'App\\Models\\User', 1, NULL, NULL, '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.0.0.0 Safari/537.36', 'success', NULL, NULL, NULL, NULL, '2026-09-12 11:52:57', '2026-09-12 11:52:57', NULL);

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

--
-- Table structure for table `branches`
--

CREATE TABLE `branches` (
  `branches_id` bigint(20) UNSIGNED NOT NULL,
  `company_id` bigint(20) UNSIGNED NOT NULL,
  `branch_name` varchar(100) NOT NULL,
  `branch_code` varchar(50) NOT NULL,
  `address` text DEFAULT NULL,
  `phone` varchar(20) DEFAULT NULL,
  `email` varchar(100) DEFAULT NULL,
  `status` enum('active','inactive','suspended') NOT NULL DEFAULT 'active',
  `is_deleted` tinyint(1) NOT NULL DEFAULT 0,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `branches`
--

INSERT INTO `branches` (`branches_id`, `company_id`, `branch_name`, `branch_code`, `address`, `phone`, `email`, `status`, `is_deleted`, `created_by`, `updated_by`, `deleted_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 1, 'Head Office', 'HQ-001', 'Kampala, Uganda', '+256 700 000 000', 'hq@mtisolutions.com', 'active', 0, NULL, NULL, NULL, '2026-09-12 06:46:58', '2026-09-12 06:46:58', NULL);

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

--
-- Table structure for table `cache`
--

CREATE TABLE `cache` (
  `key` varchar(255) NOT NULL,
  `value` mediumtext NOT NULL,
  `expiration` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `cache`
--

INSERT INTO `cache` (`key`, `value`, `expiration`) VALUES
('qms-cache-kpi.overview', 'a:7:{s:12:\"generated_at\";O:25:\"Illuminate\\Support\\Carbon\":3:{s:4:\"date\";s:26:\"2026-09-12 18:21:02.715432\";s:13:\"timezone_type\";i:3;s:8:\"timezone\";s:3:\"UTC\";}s:10:\"deviations\";a:10:{s:5:\"total\";i:0;s:4:\"open\";i:0;s:7:\"overdue\";i:0;s:8:\"critical\";i:0;s:9:\"emergency\";i:0;s:17:\"closed_this_month\";i:0;s:12:\"avg_age_days\";N;s:9:\"trend_30d\";a:30:{i:0;a:3:{s:4:\"date\";s:10:\"2026-08-14\";s:5:\"label\";s:6:\"Aug 14\";s:5:\"count\";i:0;}i:1;a:3:{s:4:\"date\";s:10:\"2026-08-15\";s:5:\"label\";s:6:\"Aug 15\";s:5:\"count\";i:0;}i:2;a:3:{s:4:\"date\";s:10:\"2026-08-16\";s:5:\"label\";s:6:\"Aug 16\";s:5:\"count\";i:0;}i:3;a:3:{s:4:\"date\";s:10:\"2026-08-17\";s:5:\"label\";s:6:\"Aug 17\";s:5:\"count\";i:0;}i:4;a:3:{s:4:\"date\";s:10:\"2026-08-18\";s:5:\"label\";s:6:\"Aug 18\";s:5:\"count\";i:0;}i:5;a:3:{s:4:\"date\";s:10:\"2026-08-19\";s:5:\"label\";s:6:\"Aug 19\";s:5:\"count\";i:0;}i:6;a:3:{s:4:\"date\";s:10:\"2026-08-20\";s:5:\"label\";s:6:\"Aug 20\";s:5:\"count\";i:0;}i:7;a:3:{s:4:\"date\";s:10:\"2026-08-21\";s:5:\"label\";s:6:\"Aug 21\";s:5:\"count\";i:0;}i:8;a:3:{s:4:\"date\";s:10:\"2026-08-22\";s:5:\"label\";s:6:\"Aug 22\";s:5:\"count\";i:0;}i:9;a:3:{s:4:\"date\";s:10:\"2026-08-23\";s:5:\"label\";s:6:\"Aug 23\";s:5:\"count\";i:0;}i:10;a:3:{s:4:\"date\";s:10:\"2026-08-24\";s:5:\"label\";s:6:\"Aug 24\";s:5:\"count\";i:0;}i:11;a:3:{s:4:\"date\";s:10:\"2026-08-25\";s:5:\"label\";s:6:\"Aug 25\";s:5:\"count\";i:0;}i:12;a:3:{s:4:\"date\";s:10:\"2026-08-26\";s:5:\"label\";s:6:\"Aug 26\";s:5:\"count\";i:0;}i:13;a:3:{s:4:\"date\";s:10:\"2026-08-27\";s:5:\"label\";s:6:\"Aug 27\";s:5:\"count\";i:0;}i:14;a:3:{s:4:\"date\";s:10:\"2026-08-28\";s:5:\"label\";s:6:\"Aug 28\";s:5:\"count\";i:0;}i:15;a:3:{s:4:\"date\";s:10:\"2026-08-29\";s:5:\"label\";s:6:\"Aug 29\";s:5:\"count\";i:0;}i:16;a:3:{s:4:\"date\";s:10:\"2026-08-30\";s:5:\"label\";s:6:\"Aug 30\";s:5:\"count\";i:0;}i:17;a:3:{s:4:\"date\";s:10:\"2026-08-31\";s:5:\"label\";s:6:\"Aug 31\";s:5:\"count\";i:0;}i:18;a:3:{s:4:\"date\";s:10:\"2026-09-01\";s:5:\"label\";s:5:\"Sep 1\";s:5:\"count\";i:0;}i:19;a:3:{s:4:\"date\";s:10:\"2026-09-02\";s:5:\"label\";s:5:\"Sep 2\";s:5:\"count\";i:0;}i:20;a:3:{s:4:\"date\";s:10:\"2026-09-03\";s:5:\"label\";s:5:\"Sep 3\";s:5:\"count\";i:0;}i:21;a:3:{s:4:\"date\";s:10:\"2026-09-04\";s:5:\"label\";s:5:\"Sep 4\";s:5:\"count\";i:0;}i:22;a:3:{s:4:\"date\";s:10:\"2026-09-05\";s:5:\"label\";s:5:\"Sep 5\";s:5:\"count\";i:0;}i:23;a:3:{s:4:\"date\";s:10:\"2026-09-06\";s:5:\"label\";s:5:\"Sep 6\";s:5:\"count\";i:0;}i:24;a:3:{s:4:\"date\";s:10:\"2026-09-07\";s:5:\"label\";s:5:\"Sep 7\";s:5:\"count\";i:0;}i:25;a:3:{s:4:\"date\";s:10:\"2026-09-08\";s:5:\"label\";s:5:\"Sep 8\";s:5:\"count\";i:0;}i:26;a:3:{s:4:\"date\";s:10:\"2026-09-09\";s:5:\"label\";s:5:\"Sep 9\";s:5:\"count\";i:0;}i:27;a:3:{s:4:\"date\";s:10:\"2026-09-10\";s:5:\"label\";s:6:\"Sep 10\";s:5:\"count\";i:0;}i:28;a:3:{s:4:\"date\";s:10:\"2026-09-11\";s:5:\"label\";s:6:\"Sep 11\";s:5:\"count\";i:0;}i:29;a:3:{s:4:\"date\";s:10:\"2026-09-12\";s:5:\"label\";s:6:\"Sep 12\";s:5:\"count\";i:0;}}s:9:\"by_status\";a:0:{}s:8:\"by_phase\";a:0:{}}s:4:\"capa\";a:10:{s:5:\"total\";i:0;s:4:\"open\";i:0;s:7:\"overdue\";i:0;s:22:\"awaiting_effectiveness\";i:0;s:17:\"closed_this_month\";i:0;s:12:\"avg_age_days\";N;s:20:\"on_time_closure_rate\";N;s:9:\"trend_30d\";a:30:{i:0;a:3:{s:4:\"date\";s:10:\"2026-08-14\";s:5:\"label\";s:6:\"Aug 14\";s:5:\"count\";i:0;}i:1;a:3:{s:4:\"date\";s:10:\"2026-08-15\";s:5:\"label\";s:6:\"Aug 15\";s:5:\"count\";i:0;}i:2;a:3:{s:4:\"date\";s:10:\"2026-08-16\";s:5:\"label\";s:6:\"Aug 16\";s:5:\"count\";i:0;}i:3;a:3:{s:4:\"date\";s:10:\"2026-08-17\";s:5:\"label\";s:6:\"Aug 17\";s:5:\"count\";i:0;}i:4;a:3:{s:4:\"date\";s:10:\"2026-08-18\";s:5:\"label\";s:6:\"Aug 18\";s:5:\"count\";i:0;}i:5;a:3:{s:4:\"date\";s:10:\"2026-08-19\";s:5:\"label\";s:6:\"Aug 19\";s:5:\"count\";i:0;}i:6;a:3:{s:4:\"date\";s:10:\"2026-08-20\";s:5:\"label\";s:6:\"Aug 20\";s:5:\"count\";i:0;}i:7;a:3:{s:4:\"date\";s:10:\"2026-08-21\";s:5:\"label\";s:6:\"Aug 21\";s:5:\"count\";i:0;}i:8;a:3:{s:4:\"date\";s:10:\"2026-08-22\";s:5:\"label\";s:6:\"Aug 22\";s:5:\"count\";i:0;}i:9;a:3:{s:4:\"date\";s:10:\"2026-08-23\";s:5:\"label\";s:6:\"Aug 23\";s:5:\"count\";i:0;}i:10;a:3:{s:4:\"date\";s:10:\"2026-08-24\";s:5:\"label\";s:6:\"Aug 24\";s:5:\"count\";i:0;}i:11;a:3:{s:4:\"date\";s:10:\"2026-08-25\";s:5:\"label\";s:6:\"Aug 25\";s:5:\"count\";i:0;}i:12;a:3:{s:4:\"date\";s:10:\"2026-08-26\";s:5:\"label\";s:6:\"Aug 26\";s:5:\"count\";i:0;}i:13;a:3:{s:4:\"date\";s:10:\"2026-08-27\";s:5:\"label\";s:6:\"Aug 27\";s:5:\"count\";i:0;}i:14;a:3:{s:4:\"date\";s:10:\"2026-08-28\";s:5:\"label\";s:6:\"Aug 28\";s:5:\"count\";i:0;}i:15;a:3:{s:4:\"date\";s:10:\"2026-08-29\";s:5:\"label\";s:6:\"Aug 29\";s:5:\"count\";i:0;}i:16;a:3:{s:4:\"date\";s:10:\"2026-08-30\";s:5:\"label\";s:6:\"Aug 30\";s:5:\"count\";i:0;}i:17;a:3:{s:4:\"date\";s:10:\"2026-08-31\";s:5:\"label\";s:6:\"Aug 31\";s:5:\"count\";i:0;}i:18;a:3:{s:4:\"date\";s:10:\"2026-09-01\";s:5:\"label\";s:5:\"Sep 1\";s:5:\"count\";i:0;}i:19;a:3:{s:4:\"date\";s:10:\"2026-09-02\";s:5:\"label\";s:5:\"Sep 2\";s:5:\"count\";i:0;}i:20;a:3:{s:4:\"date\";s:10:\"2026-09-03\";s:5:\"label\";s:5:\"Sep 3\";s:5:\"count\";i:0;}i:21;a:3:{s:4:\"date\";s:10:\"2026-09-04\";s:5:\"label\";s:5:\"Sep 4\";s:5:\"count\";i:0;}i:22;a:3:{s:4:\"date\";s:10:\"2026-09-05\";s:5:\"label\";s:5:\"Sep 5\";s:5:\"count\";i:0;}i:23;a:3:{s:4:\"date\";s:10:\"2026-09-06\";s:5:\"label\";s:5:\"Sep 6\";s:5:\"count\";i:0;}i:24;a:3:{s:4:\"date\";s:10:\"2026-09-07\";s:5:\"label\";s:5:\"Sep 7\";s:5:\"count\";i:0;}i:25;a:3:{s:4:\"date\";s:10:\"2026-09-08\";s:5:\"label\";s:5:\"Sep 8\";s:5:\"count\";i:0;}i:26;a:3:{s:4:\"date\";s:10:\"2026-09-09\";s:5:\"label\";s:5:\"Sep 9\";s:5:\"count\";i:0;}i:27;a:3:{s:4:\"date\";s:10:\"2026-09-10\";s:5:\"label\";s:6:\"Sep 10\";s:5:\"count\";i:0;}i:28;a:3:{s:4:\"date\";s:10:\"2026-09-11\";s:5:\"label\";s:6:\"Sep 11\";s:5:\"count\";i:0;}i:29;a:3:{s:4:\"date\";s:10:\"2026-09-12\";s:5:\"label\";s:6:\"Sep 12\";s:5:\"count\";i:0;}}s:9:\"by_status\";a:0:{}s:7:\"by_type\";a:0:{}}s:14:\"change_control\";a:11:{s:5:\"total\";i:0;s:4:\"open\";i:0;s:7:\"overdue\";i:0;s:16:\"pending_approval\";i:0;s:8:\"critical\";i:0;s:17:\"closed_this_month\";i:0;s:12:\"avg_age_days\";N;s:23:\"avg_implementation_days\";N;s:9:\"trend_30d\";a:30:{i:0;a:3:{s:4:\"date\";s:10:\"2026-08-14\";s:5:\"label\";s:6:\"Aug 14\";s:5:\"count\";i:0;}i:1;a:3:{s:4:\"date\";s:10:\"2026-08-15\";s:5:\"label\";s:6:\"Aug 15\";s:5:\"count\";i:0;}i:2;a:3:{s:4:\"date\";s:10:\"2026-08-16\";s:5:\"label\";s:6:\"Aug 16\";s:5:\"count\";i:0;}i:3;a:3:{s:4:\"date\";s:10:\"2026-08-17\";s:5:\"label\";s:6:\"Aug 17\";s:5:\"count\";i:0;}i:4;a:3:{s:4:\"date\";s:10:\"2026-08-18\";s:5:\"label\";s:6:\"Aug 18\";s:5:\"count\";i:0;}i:5;a:3:{s:4:\"date\";s:10:\"2026-08-19\";s:5:\"label\";s:6:\"Aug 19\";s:5:\"count\";i:0;}i:6;a:3:{s:4:\"date\";s:10:\"2026-08-20\";s:5:\"label\";s:6:\"Aug 20\";s:5:\"count\";i:0;}i:7;a:3:{s:4:\"date\";s:10:\"2026-08-21\";s:5:\"label\";s:6:\"Aug 21\";s:5:\"count\";i:0;}i:8;a:3:{s:4:\"date\";s:10:\"2026-08-22\";s:5:\"label\";s:6:\"Aug 22\";s:5:\"count\";i:0;}i:9;a:3:{s:4:\"date\";s:10:\"2026-08-23\";s:5:\"label\";s:6:\"Aug 23\";s:5:\"count\";i:0;}i:10;a:3:{s:4:\"date\";s:10:\"2026-08-24\";s:5:\"label\";s:6:\"Aug 24\";s:5:\"count\";i:0;}i:11;a:3:{s:4:\"date\";s:10:\"2026-08-25\";s:5:\"label\";s:6:\"Aug 25\";s:5:\"count\";i:0;}i:12;a:3:{s:4:\"date\";s:10:\"2026-08-26\";s:5:\"label\";s:6:\"Aug 26\";s:5:\"count\";i:0;}i:13;a:3:{s:4:\"date\";s:10:\"2026-08-27\";s:5:\"label\";s:6:\"Aug 27\";s:5:\"count\";i:0;}i:14;a:3:{s:4:\"date\";s:10:\"2026-08-28\";s:5:\"label\";s:6:\"Aug 28\";s:5:\"count\";i:0;}i:15;a:3:{s:4:\"date\";s:10:\"2026-08-29\";s:5:\"label\";s:6:\"Aug 29\";s:5:\"count\";i:0;}i:16;a:3:{s:4:\"date\";s:10:\"2026-08-30\";s:5:\"label\";s:6:\"Aug 30\";s:5:\"count\";i:0;}i:17;a:3:{s:4:\"date\";s:10:\"2026-08-31\";s:5:\"label\";s:6:\"Aug 31\";s:5:\"count\";i:0;}i:18;a:3:{s:4:\"date\";s:10:\"2026-09-01\";s:5:\"label\";s:5:\"Sep 1\";s:5:\"count\";i:0;}i:19;a:3:{s:4:\"date\";s:10:\"2026-09-02\";s:5:\"label\";s:5:\"Sep 2\";s:5:\"count\";i:0;}i:20;a:3:{s:4:\"date\";s:10:\"2026-09-03\";s:5:\"label\";s:5:\"Sep 3\";s:5:\"count\";i:0;}i:21;a:3:{s:4:\"date\";s:10:\"2026-09-04\";s:5:\"label\";s:5:\"Sep 4\";s:5:\"count\";i:0;}i:22;a:3:{s:4:\"date\";s:10:\"2026-09-05\";s:5:\"label\";s:5:\"Sep 5\";s:5:\"count\";i:0;}i:23;a:3:{s:4:\"date\";s:10:\"2026-09-06\";s:5:\"label\";s:5:\"Sep 6\";s:5:\"count\";i:0;}i:24;a:3:{s:4:\"date\";s:10:\"2026-09-07\";s:5:\"label\";s:5:\"Sep 7\";s:5:\"count\";i:0;}i:25;a:3:{s:4:\"date\";s:10:\"2026-09-08\";s:5:\"label\";s:5:\"Sep 8\";s:5:\"count\";i:0;}i:26;a:3:{s:4:\"date\";s:10:\"2026-09-09\";s:5:\"label\";s:5:\"Sep 9\";s:5:\"count\";i:0;}i:27;a:3:{s:4:\"date\";s:10:\"2026-09-10\";s:5:\"label\";s:6:\"Sep 10\";s:5:\"count\";i:0;}i:28;a:3:{s:4:\"date\";s:10:\"2026-09-11\";s:5:\"label\";s:6:\"Sep 11\";s:5:\"count\";i:0;}i:29;a:3:{s:4:\"date\";s:10:\"2026-09-12\";s:5:\"label\";s:6:\"Sep 12\";s:5:\"count\";i:0;}}s:9:\"by_status\";a:0:{}s:7:\"by_type\";a:0:{}}s:10:\"complaints\";a:12:{s:5:\"total\";i:6;s:4:\"open\";i:5;s:8:\"critical\";i:3;s:18:\"reportable_pending\";i:2;s:18:\"reportable_overdue\";i:0;s:17:\"closed_this_month\";i:1;s:12:\"avg_age_days\";d:12.4;s:16:\"avg_closure_days\";d:24;s:9:\"trend_30d\";a:30:{i:0;a:3:{s:4:\"date\";s:10:\"2026-08-14\";s:5:\"label\";s:6:\"Aug 14\";s:5:\"count\";i:0;}i:1;a:3:{s:4:\"date\";s:10:\"2026-08-15\";s:5:\"label\";s:6:\"Aug 15\";s:5:\"count\";i:1;}i:2;a:3:{s:4:\"date\";s:10:\"2026-08-16\";s:5:\"label\";s:6:\"Aug 16\";s:5:\"count\";i:0;}i:3;a:3:{s:4:\"date\";s:10:\"2026-08-17\";s:5:\"label\";s:6:\"Aug 17\";s:5:\"count\";i:0;}i:4;a:3:{s:4:\"date\";s:10:\"2026-08-18\";s:5:\"label\";s:6:\"Aug 18\";s:5:\"count\";i:0;}i:5;a:3:{s:4:\"date\";s:10:\"2026-08-19\";s:5:\"label\";s:6:\"Aug 19\";s:5:\"count\";i:0;}i:6;a:3:{s:4:\"date\";s:10:\"2026-08-20\";s:5:\"label\";s:6:\"Aug 20\";s:5:\"count\";i:0;}i:7;a:3:{s:4:\"date\";s:10:\"2026-08-21\";s:5:\"label\";s:6:\"Aug 21\";s:5:\"count\";i:0;}i:8;a:3:{s:4:\"date\";s:10:\"2026-08-22\";s:5:\"label\";s:6:\"Aug 22\";s:5:\"count\";i:0;}i:9;a:3:{s:4:\"date\";s:10:\"2026-08-23\";s:5:\"label\";s:6:\"Aug 23\";s:5:\"count\";i:1;}i:10;a:3:{s:4:\"date\";s:10:\"2026-08-24\";s:5:\"label\";s:6:\"Aug 24\";s:5:\"count\";i:0;}i:11;a:3:{s:4:\"date\";s:10:\"2026-08-25\";s:5:\"label\";s:6:\"Aug 25\";s:5:\"count\";i:0;}i:12;a:3:{s:4:\"date\";s:10:\"2026-08-26\";s:5:\"label\";s:6:\"Aug 26\";s:5:\"count\";i:0;}i:13;a:3:{s:4:\"date\";s:10:\"2026-08-27\";s:5:\"label\";s:6:\"Aug 27\";s:5:\"count\";i:0;}i:14;a:3:{s:4:\"date\";s:10:\"2026-08-28\";s:5:\"label\";s:6:\"Aug 28\";s:5:\"count\";i:0;}i:15;a:3:{s:4:\"date\";s:10:\"2026-08-29\";s:5:\"label\";s:6:\"Aug 29\";s:5:\"count\";i:0;}i:16;a:3:{s:4:\"date\";s:10:\"2026-08-30\";s:5:\"label\";s:6:\"Aug 30\";s:5:\"count\";i:0;}i:17;a:3:{s:4:\"date\";s:10:\"2026-08-31\";s:5:\"label\";s:6:\"Aug 31\";s:5:\"count\";i:0;}i:18;a:3:{s:4:\"date\";s:10:\"2026-09-01\";s:5:\"label\";s:5:\"Sep 1\";s:5:\"count\";i:0;}i:19;a:3:{s:4:\"date\";s:10:\"2026-09-02\";s:5:\"label\";s:5:\"Sep 2\";s:5:\"count\";i:0;}i:20;a:3:{s:4:\"date\";s:10:\"2026-09-03\";s:5:\"label\";s:5:\"Sep 3\";s:5:\"count\";i:0;}i:21;a:3:{s:4:\"date\";s:10:\"2026-09-04\";s:5:\"label\";s:5:\"Sep 4\";s:5:\"count\";i:1;}i:22;a:3:{s:4:\"date\";s:10:\"2026-09-05\";s:5:\"label\";s:5:\"Sep 5\";s:5:\"count\";i:0;}i:23;a:3:{s:4:\"date\";s:10:\"2026-09-06\";s:5:\"label\";s:5:\"Sep 6\";s:5:\"count\";i:0;}i:24;a:3:{s:4:\"date\";s:10:\"2026-09-07\";s:5:\"label\";s:5:\"Sep 7\";s:5:\"count\";i:1;}i:25;a:3:{s:4:\"date\";s:10:\"2026-09-08\";s:5:\"label\";s:5:\"Sep 8\";s:5:\"count\";i:0;}i:26;a:3:{s:4:\"date\";s:10:\"2026-09-09\";s:5:\"label\";s:5:\"Sep 9\";s:5:\"count\";i:0;}i:27;a:3:{s:4:\"date\";s:10:\"2026-09-10\";s:5:\"label\";s:6:\"Sep 10\";s:5:\"count\";i:0;}i:28;a:3:{s:4:\"date\";s:10:\"2026-09-11\";s:5:\"label\";s:6:\"Sep 11\";s:5:\"count\";i:1;}i:29;a:3:{s:4:\"date\";s:10:\"2026-09-12\";s:5:\"label\";s:6:\"Sep 12\";s:5:\"count\";i:0;}}s:9:\"by_status\";a:5:{i:0;a:2:{s:5:\"label\";E:45:\"App\\Enums\\ComplaintStatus:UNDER_INVESTIGATION\";s:5:\"count\";i:2;}i:1;a:2:{s:5:\"label\";E:34:\"App\\Enums\\ComplaintStatus:REPORTED\";s:5:\"count\";i:1;}i:2;a:2:{s:5:\"label\";E:40:\"App\\Enums\\ComplaintStatus:PENDING_REPORT\";s:5:\"count\";i:1;}i:3;a:2:{s:5:\"label\";E:32:\"App\\Enums\\ComplaintStatus:LOGGED\";s:5:\"count\";i:1;}i:4;a:2:{s:5:\"label\";E:32:\"App\\Enums\\ComplaintStatus:CLOSED\";s:5:\"count\";i:1;}}s:11:\"by_severity\";a:3:{i:0;a:2:{s:5:\"label\";E:36:\"App\\Enums\\ComplaintSeverity:CRITICAL\";s:5:\"count\";i:3;}i:1;a:2:{s:5:\"label\";E:33:\"App\\Enums\\ComplaintSeverity:MAJOR\";s:5:\"count\";i:2;}i:2;a:2:{s:5:\"label\";E:33:\"App\\Enums\\ComplaintSeverity:MINOR\";s:5:\"count\";i:1;}}s:9:\"by_source\";a:3:{i:0;a:2:{s:5:\"label\";E:34:\"App\\Enums\\ComplaintSource:CUSTOMER\";s:5:\"count\";i:4;}i:1;a:2:{s:5:\"label\";E:37:\"App\\Enums\\ComplaintSource:DISTRIBUTOR\";s:5:\"count\";i:1;}i:2;a:2:{s:5:\"label\";E:34:\"App\\Enums\\ComplaintSource:INTERNAL\";s:5:\"count\";i:1;}}}s:6:\"audits\";a:10:{s:5:\"total\";i:3;s:4:\"open\";i:1;s:11:\"in_progress\";i:1;s:7:\"overdue\";i:0;s:13:\"open_findings\";i:4;s:8:\"major_nc\";i:1;s:16:\"closed_this_year\";i:2;s:9:\"trend_30d\";a:30:{i:0;a:3:{s:4:\"date\";s:10:\"2026-08-14\";s:5:\"label\";s:6:\"Aug 14\";s:5:\"count\";i:0;}i:1;a:3:{s:4:\"date\";s:10:\"2026-08-15\";s:5:\"label\";s:6:\"Aug 15\";s:5:\"count\";i:0;}i:2;a:3:{s:4:\"date\";s:10:\"2026-08-16\";s:5:\"label\";s:6:\"Aug 16\";s:5:\"count\";i:0;}i:3;a:3:{s:4:\"date\";s:10:\"2026-08-17\";s:5:\"label\";s:6:\"Aug 17\";s:5:\"count\";i:0;}i:4;a:3:{s:4:\"date\";s:10:\"2026-08-18\";s:5:\"label\";s:6:\"Aug 18\";s:5:\"count\";i:0;}i:5;a:3:{s:4:\"date\";s:10:\"2026-08-19\";s:5:\"label\";s:6:\"Aug 19\";s:5:\"count\";i:0;}i:6;a:3:{s:4:\"date\";s:10:\"2026-08-20\";s:5:\"label\";s:6:\"Aug 20\";s:5:\"count\";i:0;}i:7;a:3:{s:4:\"date\";s:10:\"2026-08-21\";s:5:\"label\";s:6:\"Aug 21\";s:5:\"count\";i:0;}i:8;a:3:{s:4:\"date\";s:10:\"2026-08-22\";s:5:\"label\";s:6:\"Aug 22\";s:5:\"count\";i:0;}i:9;a:3:{s:4:\"date\";s:10:\"2026-08-23\";s:5:\"label\";s:6:\"Aug 23\";s:5:\"count\";i:0;}i:10;a:3:{s:4:\"date\";s:10:\"2026-08-24\";s:5:\"label\";s:6:\"Aug 24\";s:5:\"count\";i:0;}i:11;a:3:{s:4:\"date\";s:10:\"2026-08-25\";s:5:\"label\";s:6:\"Aug 25\";s:5:\"count\";i:0;}i:12;a:3:{s:4:\"date\";s:10:\"2026-08-26\";s:5:\"label\";s:6:\"Aug 26\";s:5:\"count\";i:0;}i:13;a:3:{s:4:\"date\";s:10:\"2026-08-27\";s:5:\"label\";s:6:\"Aug 27\";s:5:\"count\";i:0;}i:14;a:3:{s:4:\"date\";s:10:\"2026-08-28\";s:5:\"label\";s:6:\"Aug 28\";s:5:\"count\";i:0;}i:15;a:3:{s:4:\"date\";s:10:\"2026-08-29\";s:5:\"label\";s:6:\"Aug 29\";s:5:\"count\";i:0;}i:16;a:3:{s:4:\"date\";s:10:\"2026-08-30\";s:5:\"label\";s:6:\"Aug 30\";s:5:\"count\";i:0;}i:17;a:3:{s:4:\"date\";s:10:\"2026-08-31\";s:5:\"label\";s:6:\"Aug 31\";s:5:\"count\";i:0;}i:18;a:3:{s:4:\"date\";s:10:\"2026-09-01\";s:5:\"label\";s:5:\"Sep 1\";s:5:\"count\";i:0;}i:19;a:3:{s:4:\"date\";s:10:\"2026-09-02\";s:5:\"label\";s:5:\"Sep 2\";s:5:\"count\";i:0;}i:20;a:3:{s:4:\"date\";s:10:\"2026-09-03\";s:5:\"label\";s:5:\"Sep 3\";s:5:\"count\";i:0;}i:21;a:3:{s:4:\"date\";s:10:\"2026-09-04\";s:5:\"label\";s:5:\"Sep 4\";s:5:\"count\";i:0;}i:22;a:3:{s:4:\"date\";s:10:\"2026-09-05\";s:5:\"label\";s:5:\"Sep 5\";s:5:\"count\";i:0;}i:23;a:3:{s:4:\"date\";s:10:\"2026-09-06\";s:5:\"label\";s:5:\"Sep 6\";s:5:\"count\";i:0;}i:24;a:3:{s:4:\"date\";s:10:\"2026-09-07\";s:5:\"label\";s:5:\"Sep 7\";s:5:\"count\";i:0;}i:25;a:3:{s:4:\"date\";s:10:\"2026-09-08\";s:5:\"label\";s:5:\"Sep 8\";s:5:\"count\";i:0;}i:26;a:3:{s:4:\"date\";s:10:\"2026-09-09\";s:5:\"label\";s:5:\"Sep 9\";s:5:\"count\";i:0;}i:27;a:3:{s:4:\"date\";s:10:\"2026-09-10\";s:5:\"label\";s:6:\"Sep 10\";s:5:\"count\";i:0;}i:28;a:3:{s:4:\"date\";s:10:\"2026-09-11\";s:5:\"label\";s:6:\"Sep 11\";s:5:\"count\";i:0;}i:29;a:3:{s:4:\"date\";s:10:\"2026-09-12\";s:5:\"label\";s:6:\"Sep 12\";s:5:\"count\";i:3;}}s:9:\"by_status\";a:2:{i:0;a:2:{s:5:\"label\";E:28:\"App\\Enums\\AuditStatus:CLOSED\";s:5:\"count\";i:2;}i:1;a:2:{s:5:\"label\";E:33:\"App\\Enums\\AuditStatus:IN_PROGRESS\";s:5:\"count\";i:1;}}s:7:\"by_type\";a:3:{i:0;a:2:{s:5:\"label\";E:28:\"App\\Enums\\AuditType:SUPPLIER\";s:5:\"count\";i:1;}i:1;a:2:{s:5:\"label\";E:30:\"App\\Enums\\AuditType:REGULATORY\";s:5:\"count\";i:1;}i:2;a:2:{s:5:\"label\";E:28:\"App\\Enums\\AuditType:INTERNAL\";s:5:\"count\";i:1;}}}s:5:\"cross\";a:4:{s:10:\"total_open\";i:6;s:13:\"total_overdue\";i:0;s:13:\"aging_buckets\";a:4:{s:3:\"0_7\";i:6;s:4:\"8_30\";i:0;s:5:\"31_90\";i:0;s:7:\"90_plus\";i:0;}s:19:\"supplier_requal_due\";i:2;}}', 1789237323),
('qms-cache-qms.dashboard', 'a:9:{s:12:\"generated_at\";O:25:\"Illuminate\\Support\\Carbon\":3:{s:4:\"date\";s:26:\"2026-09-12 18:21:07.056279\";s:13:\"timezone_type\";i:3;s:8:\"timezone\";s:3:\"UTC\";}s:9:\"documents\";a:5:{s:5:\"label\";s:9:\"Documents\";s:4:\"icon\";s:11:\"fa-file-alt\";s:5:\"color\";s:7:\"primary\";s:5:\"route\";s:15:\"documents.index\";s:7:\"metrics\";a:5:{i:0;a:5:{s:3:\"key\";s:5:\"total\";s:5:\"label\";s:5:\"Total\";s:5:\"value\";i:10;s:5:\"color\";s:7:\"primary\";s:5:\"route\";s:15:\"documents.index\";}i:1;a:6:{s:3:\"key\";s:14:\"pending_review\";s:5:\"label\";s:14:\"Pending Review\";s:5:\"value\";i:1;s:5:\"color\";s:4:\"info\";s:5:\"route\";s:15:\"documents.index\";s:5:\"query\";a:1:{s:15:\"document_status\";s:12:\"Under Review\";}}i:2;a:6:{s:3:\"key\";s:16:\"pending_approval\";s:5:\"label\";s:16:\"Pending Approval\";s:5:\"value\";i:1;s:5:\"color\";s:7:\"warning\";s:5:\"route\";s:15:\"documents.index\";s:5:\"query\";a:1:{s:15:\"document_status\";s:8:\"Approved\";}}i:3;a:6:{s:3:\"key\";s:14:\"overdue_review\";s:5:\"label\";s:14:\"Overdue Review\";s:5:\"value\";i:0;s:5:\"color\";s:6:\"danger\";s:5:\"route\";s:15:\"documents.index\";s:5:\"query\";a:2:{s:15:\"document_status\";s:12:\"Under Review\";s:7:\"overdue\";i:1;}}i:4;a:6:{s:3:\"key\";s:8:\"obsolete\";s:5:\"label\";s:8:\"Obsolete\";s:5:\"value\";i:4;s:5:\"color\";s:9:\"secondary\";s:5:\"route\";s:15:\"documents.index\";s:5:\"query\";a:1:{s:15:\"document_status\";s:8:\"Obsolete\";}}}}s:8:\"training\";a:5:{s:5:\"label\";s:8:\"Training\";s:4:\"icon\";s:17:\"fa-graduation-cap\";s:5:\"color\";s:4:\"info\";s:5:\"route\";s:24:\"training.trainings.index\";s:7:\"metrics\";a:3:{i:0;a:6:{s:3:\"key\";s:9:\"completed\";s:5:\"label\";s:9:\"Completed\";s:5:\"value\";i:0;s:5:\"color\";s:7:\"success\";s:5:\"route\";s:24:\"training.trainings.index\";s:5:\"query\";a:1:{s:6:\"status\";s:9:\"Completed\";}}i:1;a:6:{s:3:\"key\";s:7:\"pending\";s:5:\"label\";s:7:\"Pending\";s:5:\"value\";i:0;s:5:\"color\";s:4:\"info\";s:5:\"route\";s:24:\"training.trainings.index\";s:5:\"query\";a:1:{s:6:\"status\";s:9:\"Scheduled\";}}i:2;a:6:{s:3:\"key\";s:7:\"overdue\";s:5:\"label\";s:7:\"Overdue\";s:5:\"value\";i:0;s:5:\"color\";s:6:\"danger\";s:5:\"route\";s:24:\"training.trainings.index\";s:5:\"query\";a:1:{s:6:\"status\";s:7:\"overdue\";}}}}s:4:\"capa\";a:5:{s:5:\"label\";s:4:\"CAPA\";s:4:\"icon\";s:8:\"fa-tasks\";s:5:\"color\";s:7:\"success\";s:5:\"route\";s:10:\"capa.index\";s:7:\"metrics\";a:3:{i:0;a:5:{s:3:\"key\";s:4:\"open\";s:5:\"label\";s:4:\"Open\";s:5:\"value\";i:0;s:5:\"color\";s:4:\"info\";s:5:\"route\";s:10:\"capa.index\";}i:1;a:6:{s:3:\"key\";s:7:\"overdue\";s:5:\"label\";s:7:\"Overdue\";s:5:\"value\";i:0;s:5:\"color\";s:6:\"danger\";s:5:\"route\";s:10:\"capa.index\";s:5:\"query\";a:1:{s:7:\"overdue\";i:1;}}i:2;a:6:{s:3:\"key\";s:21:\"effectiveness_pending\";s:5:\"label\";s:21:\"Effectiveness Pending\";s:5:\"value\";i:0;s:5:\"color\";s:7:\"warning\";s:5:\"route\";s:10:\"capa.index\";s:5:\"query\";a:1:{s:6:\"status\";s:19:\"EFFECTIVENESS_CHECK\";}}}}s:10:\"deviations\";a:5:{s:5:\"label\";s:10:\"Deviations\";s:4:\"icon\";s:23:\"fa-exclamation-triangle\";s:5:\"color\";s:7:\"warning\";s:5:\"route\";s:16:\"deviations.index\";s:7:\"metrics\";a:3:{i:0;a:6:{s:3:\"key\";s:4:\"open\";s:5:\"label\";s:4:\"Open\";s:5:\"value\";i:0;s:5:\"color\";s:7:\"warning\";s:5:\"route\";s:16:\"deviations.index\";s:5:\"query\";a:1:{s:6:\"filter\";s:4:\"open\";}}i:1;a:6:{s:3:\"key\";s:8:\"critical\";s:5:\"label\";s:8:\"Critical\";s:5:\"value\";i:0;s:5:\"color\";s:6:\"danger\";s:5:\"route\";s:16:\"deviations.index\";s:5:\"query\";a:1:{s:10:\"risk_level\";s:8:\"CRITICAL\";}}i:2;a:6:{s:3:\"key\";s:7:\"overdue\";s:5:\"label\";s:7:\"Overdue\";s:5:\"value\";i:0;s:5:\"color\";s:6:\"danger\";s:5:\"route\";s:16:\"deviations.index\";s:5:\"query\";a:1:{s:7:\"overdue\";i:1;}}}}s:6:\"audits\";a:5:{s:5:\"label\";s:6:\"Audits\";s:4:\"icon\";s:17:\"fa-clipboard-list\";s:5:\"color\";s:9:\"secondary\";s:5:\"route\";s:12:\"audits.index\";s:7:\"metrics\";a:3:{i:0;a:6:{s:3:\"key\";s:7:\"planned\";s:5:\"label\";s:7:\"Planned\";s:5:\"value\";i:0;s:5:\"color\";s:4:\"info\";s:5:\"route\";s:12:\"audits.index\";s:5:\"query\";a:1:{s:5:\"phase\";s:8:\"PLANNING\";}}i:1;a:6:{s:3:\"key\";s:11:\"in_progress\";s:5:\"label\";s:11:\"In Progress\";s:5:\"value\";i:1;s:5:\"color\";s:7:\"primary\";s:5:\"route\";s:12:\"audits.index\";s:5:\"query\";a:1:{s:5:\"phase\";s:9:\"EXECUTION\";}}i:2;a:5:{s:3:\"key\";s:16:\"findings_overdue\";s:5:\"label\";s:16:\"Findings Overdue\";s:5:\"value\";i:0;s:5:\"color\";s:6:\"danger\";s:5:\"route\";s:12:\"audits.index\";}}}s:6:\"change\";a:5:{s:5:\"label\";s:14:\"Change Control\";s:4:\"icon\";s:15:\"fa-exchange-alt\";s:5:\"color\";s:7:\"primary\";s:5:\"route\";s:20:\"change-control.index\";s:7:\"metrics\";a:3:{i:0;a:5:{s:3:\"key\";s:4:\"open\";s:5:\"label\";s:4:\"Open\";s:5:\"value\";i:0;s:5:\"color\";s:7:\"primary\";s:5:\"route\";s:20:\"change-control.index\";}i:1;a:6:{s:3:\"key\";s:16:\"pending_approval\";s:5:\"label\";s:16:\"Pending Approval\";s:5:\"value\";i:0;s:5:\"color\";s:7:\"warning\";s:5:\"route\";s:20:\"change-control.index\";s:5:\"query\";a:1:{s:6:\"status\";s:16:\"PENDING_APPROVAL\";}}i:2;a:6:{s:3:\"key\";s:7:\"overdue\";s:5:\"label\";s:7:\"Overdue\";s:5:\"value\";i:0;s:5:\"color\";s:6:\"danger\";s:5:\"route\";s:20:\"change-control.index\";s:5:\"query\";a:1:{s:7:\"overdue\";i:1;}}}}s:10:\"complaints\";a:5:{s:5:\"label\";s:10:\"Complaints\";s:4:\"icon\";s:15:\"fa-comment-dots\";s:5:\"color\";s:4:\"info\";s:5:\"route\";s:16:\"complaints.index\";s:7:\"metrics\";a:3:{i:0;a:5:{s:3:\"key\";s:4:\"open\";s:5:\"label\";s:4:\"Open\";s:5:\"value\";i:5;s:5:\"color\";s:4:\"info\";s:5:\"route\";s:16:\"complaints.index\";}i:1;a:6:{s:3:\"key\";s:8:\"critical\";s:5:\"label\";s:8:\"Critical\";s:5:\"value\";i:3;s:5:\"color\";s:6:\"danger\";s:5:\"route\";s:16:\"complaints.index\";s:5:\"query\";a:1:{s:8:\"severity\";s:8:\"CRITICAL\";}}i:2;a:6:{s:3:\"key\";s:7:\"overdue\";s:5:\"label\";s:7:\"Overdue\";s:5:\"value\";i:0;s:5:\"color\";s:7:\"warning\";s:5:\"route\";s:16:\"complaints.index\";s:5:\"query\";a:2:{s:10:\"reportable\";i:1;s:7:\"overdue\";i:1;}}}}s:5:\"risks\";a:5:{s:5:\"label\";s:5:\"Risks\";s:4:\"icon\";s:13:\"fa-shield-alt\";s:5:\"color\";s:4:\"dark\";s:5:\"route\";s:22:\"risk-assessments.index\";s:7:\"metrics\";a:3:{i:0;a:6:{s:3:\"key\";s:4:\"high\";s:5:\"label\";s:4:\"High\";s:5:\"value\";i:1;s:5:\"color\";s:7:\"warning\";s:5:\"route\";s:22:\"risk-assessments.index\";s:5:\"query\";a:1:{s:7:\"outcome\";s:4:\"HIGH\";}}i:1;a:6:{s:3:\"key\";s:8:\"critical\";s:5:\"label\";s:8:\"Critical\";s:5:\"value\";i:0;s:5:\"color\";s:6:\"danger\";s:5:\"route\";s:22:\"risk-assessments.index\";s:5:\"query\";a:1:{s:7:\"outcome\";s:8:\"CRITICAL\";}}i:2;a:5:{s:3:\"key\";s:11:\"reviews_due\";s:5:\"label\";s:11:\"Reviews Due\";s:5:\"value\";i:0;s:5:\"color\";s:4:\"info\";s:5:\"route\";s:22:\"risk-assessments.index\";}}}}', 1789237327);

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

--
-- Table structure for table `cache_locks`
--

CREATE TABLE `cache_locks` (
  `key` varchar(255) NOT NULL,
  `owner` varchar(255) NOT NULL,
  `expiration` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `capa_action_plan`
--

CREATE TABLE `capa_action_plan` (
  `action_id` int(10) UNSIGNED NOT NULL,
  `capa_id` int(10) UNSIGNED NOT NULL,
  `action_type` enum('Correction','Corrective Action','Preventive Action') NOT NULL DEFAULT 'Corrective Action',
  `action_description` text NOT NULL,
  `responsible_person_id` int(10) UNSIGNED NOT NULL,
  `due_date` date NOT NULL,
  `completion_date` date DEFAULT NULL,
  `effectiveness_notes` text DEFAULT NULL,
  `status` enum('Not Started','In Progress','Completed','Verified','Overdue','Cancelled') NOT NULL DEFAULT 'Not Started',
  `created_date` timestamp NOT NULL DEFAULT current_timestamp(),
  `created_by` int(10) UNSIGNED NOT NULL,
  `updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
  `updated_by` int(10) UNSIGNED DEFAULT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `deleted_by` int(10) UNSIGNED DEFAULT NULL,
  `is_deleted` tinyint(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `capa_audit_trails`
--

CREATE TABLE `capa_audit_trails` (
  `audit_id` int(10) UNSIGNED NOT NULL,
  `capa_id` int(10) UNSIGNED NOT NULL,
  `user_id` int(10) UNSIGNED DEFAULT NULL,
  `action_type` varchar(50) NOT NULL,
  `action_description` text NOT NULL,
  `old_values` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`old_values`)),
  `new_values` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`new_values`)),
  `changed_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `capa_closure`
--

CREATE TABLE `capa_closure` (
  `closure_id` int(10) UNSIGNED NOT NULL,
  `capa_id` int(10) UNSIGNED NOT NULL,
  `closure_justification` text NOT NULL,
  `closure_date` date NOT NULL,
  `closed_by` int(10) UNSIGNED NOT NULL,
  `final_status` enum('Closed','Closed-Effective','Closed-Ineffective') NOT NULL DEFAULT 'Closed',
  `created_date` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `capa_documents`
--

CREATE TABLE `capa_documents` (
  `document_id` int(10) UNSIGNED NOT NULL,
  `capa_id` int(10) UNSIGNED NOT NULL,
  `document_type` varchar(50) NOT NULL,
  `file_name` varchar(255) NOT NULL,
  `file_path` varchar(500) NOT NULL,
  `file_type` varchar(50) DEFAULT NULL,
  `description` varchar(255) DEFAULT NULL,
  `uploaded_by` int(10) UNSIGNED NOT NULL,
  `upload_date` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
  `updated_by` int(10) UNSIGNED DEFAULT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `deleted_by` int(10) UNSIGNED DEFAULT NULL,
  `is_deleted` tinyint(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `capa_effectiveness`
--

CREATE TABLE `capa_effectiveness` (
  `effectiveness_id` int(10) UNSIGNED NOT NULL,
  `capa_id` int(10) UNSIGNED NOT NULL,
  `check_methodology` text NOT NULL,
  `success_criteria` text NOT NULL,
  `monitoring_period` varchar(100) NOT NULL,
  `check_date` date DEFAULT NULL,
  `results` text DEFAULT NULL,
  `conclusion` enum('Effective','Not Effective','Partially Effective','Pending') NOT NULL DEFAULT 'Pending',
  `verified_by` int(10) UNSIGNED DEFAULT NULL,
  `verification_date` date DEFAULT NULL,
  `created_date` timestamp NOT NULL DEFAULT current_timestamp(),
  `created_by` int(10) UNSIGNED NOT NULL,
  `updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
  `updated_by` int(10) UNSIGNED DEFAULT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `deleted_by` int(10) UNSIGNED DEFAULT NULL,
  `is_deleted` tinyint(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `capa_extensions`
--

CREATE TABLE `capa_extensions` (
  `extension_id` int(10) UNSIGNED NOT NULL,
  `capa_id` int(10) UNSIGNED NOT NULL,
  `original_due_date` date NOT NULL,
  `new_due_date` date NOT NULL,
  `reason_for_extension` text NOT NULL,
  `impact_assessment` text DEFAULT NULL,
  `requested_by` int(10) UNSIGNED NOT NULL,
  `requested_date` timestamp NOT NULL DEFAULT current_timestamp(),
  `approved_by` int(10) UNSIGNED DEFAULT NULL,
  `approval_date` date DEFAULT NULL,
  `approval_status` enum('Pending','Approved','Rejected') NOT NULL DEFAULT 'Pending'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `capa_investigations`
--

CREATE TABLE `capa_investigations` (
  `investigation_id` int(10) UNSIGNED NOT NULL,
  `capa_id` int(10) UNSIGNED NOT NULL,
  `investigation_owner_id` int(10) UNSIGNED NOT NULL,
  `methodology` enum('5_WHYS','FISHBONE','FMEA','PROCESS_MAPPING','DATA_ANALYSIS','COMBINATION','OTHER') NOT NULL DEFAULT '5_WHYS',
  `investigation_scope` text DEFAULT NULL,
  `start_date` date NOT NULL,
  `end_date` date DEFAULT NULL,
  `root_cause_analysis` text DEFAULT NULL,
  `root_cause_category_id` int(10) UNSIGNED DEFAULT NULL,
  `investigation_summary` text DEFAULT NULL,
  `conclusion` text DEFAULT NULL,
  `status` enum('PENDING_APPROVAL','IN_PROGRESS','APPROVED','REJECTED','COMPLETED') NOT NULL DEFAULT 'IN_PROGRESS',
  `approved_by` int(10) UNSIGNED DEFAULT NULL,
  `approved_date` datetime DEFAULT NULL,
  `rejection_reason` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `created_by` int(10) UNSIGNED NOT NULL,
  `updated_by` int(10) UNSIGNED DEFAULT NULL,
  `deleted_by` int(10) UNSIGNED DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `capa_request`
--

CREATE TABLE `capa_request` (
  `capa_id` int(10) UNSIGNED NOT NULL,
  `capa_number` varchar(50) NOT NULL,
  `title` varchar(500) NOT NULL,
  `problem_statement` text NOT NULL,
  `capa_type` enum('CORRECTIVE','PREVENTIVE','BOTH') NOT NULL DEFAULT 'CORRECTIVE',
  `priority` enum('LOW','MEDIUM','HIGH','CRITICAL') NOT NULL DEFAULT 'MEDIUM',
  `category` enum('PROCESS','PRODUCT','EQUIPMENT','DOCUMENTATION','PERSONNEL','TRAINING','SUPPLIER','SYSTEM','ENVIRONMENT','REGULATORY','OTHER') NOT NULL DEFAULT 'PROCESS',
  `source_type` enum('DEVIATION','AUDIT','COMPLAINT','CHANGE_CONTROL','RISK_ASSESSMENT','SUPPLIER','SELF_IDENTIFIED','MANAGEMENT_REVIEW','REGULATORY','TREND_ANALYSIS','OTHER') NOT NULL DEFAULT 'SELF_IDENTIFIED',
  `source_record_id` int(10) UNSIGNED DEFAULT NULL,
  `source_reference` varchar(100) DEFAULT NULL,
  `initiated_by` int(10) UNSIGNED NOT NULL,
  `owner_user_id` int(10) UNSIGNED DEFAULT NULL,
  `investigator_id` int(10) UNSIGNED DEFAULT NULL,
  `department_id` int(10) UNSIGNED DEFAULT NULL,
  `initiated_date` date NOT NULL,
  `target_completion_date` date DEFAULT NULL,
  `implementation_due_date` date DEFAULT NULL,
  `effectiveness_check_due_date` date DEFAULT NULL,
  `actual_completion_date` date DEFAULT NULL,
  `closed_date` datetime DEFAULT NULL,
  `root_cause_summary` text DEFAULT NULL,
  `root_cause_method` varchar(60) DEFAULT NULL,
  `workflow_id` int(10) UNSIGNED DEFAULT NULL,
  `workflow_instance_id` int(10) UNSIGNED DEFAULT NULL,
  `status` enum('DRAFT','INITIATED','UNDER_REVIEW','APPROVED','ACTION_PLANNING','IMPLEMENTATION','EFFECTIVENESS_CHECK','PENDING_CLOSURE','CLOSED','REJECTED','CANCELLED','REOPENED') NOT NULL DEFAULT 'DRAFT',
  `action_status` enum('NOT_STARTED','IN_PROGRESS','COMPLETED','VERIFIED') NOT NULL DEFAULT 'NOT_STARTED',
  `approved_by` int(10) UNSIGNED DEFAULT NULL,
  `approved_date` datetime DEFAULT NULL,
  `rejection_reason` text DEFAULT NULL,
  `effectiveness_result` enum('PENDING','EFFECTIVE','PARTIALLY_EFFECTIVE','NOT_EFFECTIVE','NOT_APPLICABLE') NOT NULL DEFAULT 'PENDING',
  `effectiveness_notes` text DEFAULT NULL,
  `closure_comments` text DEFAULT NULL,
  `closed_by` int(10) UNSIGNED DEFAULT NULL,
  `reopen_count` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `reopen_reason` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `created_by` int(10) UNSIGNED NOT NULL,
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `updated_by` int(10) UNSIGNED DEFAULT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `deleted_by` int(10) UNSIGNED DEFAULT NULL,
  `is_deleted` tinyint(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `change_audit_trail`
--

CREATE TABLE `change_audit_trail` (
  `audit_id` int(10) UNSIGNED NOT NULL,
  `change_id` int(10) UNSIGNED NOT NULL,
  `user_id` int(10) UNSIGNED DEFAULT NULL,
  `action_type` varchar(50) NOT NULL,
  `action_description` text NOT NULL,
  `old_values` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`old_values`)),
  `new_values` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`new_values`)),
  `ip_address` varchar(45) DEFAULT NULL,
  `changed_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `change_control_links`
--

CREATE TABLE `change_control_links` (
  `link_id` int(10) UNSIGNED NOT NULL,
  `change_id` int(10) UNSIGNED NOT NULL,
  `linked_type` varchar(50) NOT NULL,
  `linked_id` bigint(20) UNSIGNED NOT NULL,
  `relationship` varchar(50) NOT NULL DEFAULT 'AFFECTED',
  `impact_notes` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `is_deleted` tinyint(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `change_control_master`
--

CREATE TABLE `change_control_master` (
  `change_id` int(10) UNSIGNED NOT NULL,
  `change_number` varchar(50) NOT NULL,
  `change_type` enum('PROCESS','PRODUCT','EQUIPMENT','DOCUMENT') NOT NULL,
  `change_category` enum('MINOR','MAJOR','CRITICAL') NOT NULL DEFAULT 'MINOR',
  `priority` enum('LOW','MEDIUM','HIGH','CRITICAL') NOT NULL DEFAULT 'MEDIUM',
  `title` varchar(500) NOT NULL,
  `description` text NOT NULL,
  `justification` text DEFAULT NULL,
  `expected_benefits` text DEFAULT NULL,
  `risks_if_not_implemented` text DEFAULT NULL,
  `initiated_by` int(10) UNSIGNED NOT NULL,
  `owner_user_id` int(10) UNSIGNED DEFAULT NULL,
  `department_id` int(10) UNSIGNED DEFAULT NULL,
  `initiated_date` date NOT NULL,
  `target_implementation_date` date DEFAULT NULL,
  `actual_implementation_date` date DEFAULT NULL,
  `closed_date` datetime DEFAULT NULL,
  `current_status` enum('DRAFT','SUBMITTED','UNDER_REVIEW','APPROVED','PLANNING','IMPLEMENTATION','EFFECTIVENESS_CHECK','CLOSED','REJECTED','CANCELLED') NOT NULL DEFAULT 'DRAFT',
  `current_phase` enum('INITIATION','REVIEW','APPROVAL','PLANNING','IMPLEMENTATION','EFFECTIVENESS','CLOSURE','REJECTED') NOT NULL DEFAULT 'INITIATION',
  `impact_form_schema` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`impact_form_schema`)),
  `workflow_id` int(10) UNSIGNED DEFAULT NULL,
  `workflow_instance_id` int(10) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `created_by` int(10) UNSIGNED DEFAULT NULL,
  `updated_by` int(10) UNSIGNED DEFAULT NULL,
  `deleted_by` int(10) UNSIGNED DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `is_deleted` tinyint(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `change_effectiveness_check`
--

CREATE TABLE `change_effectiveness_check` (
  `effectiveness_id` int(10) UNSIGNED NOT NULL,
  `change_id` int(10) UNSIGNED NOT NULL,
  `methodology` text NOT NULL,
  `success_criteria` text NOT NULL,
  `monitoring_period` varchar(100) DEFAULT NULL,
  `check_date` date DEFAULT NULL,
  `results` text DEFAULT NULL,
  `conclusion` enum('PENDING','EFFECTIVE','PARTIALLY_EFFECTIVE','NOT_EFFECTIVE') NOT NULL DEFAULT 'PENDING',
  `approval_status` enum('PENDING_APPROVAL','APPROVED','REJECTED') NOT NULL DEFAULT 'PENDING_APPROVAL',
  `approved_by` int(10) UNSIGNED DEFAULT NULL,
  `approved_at` datetime DEFAULT NULL,
  `approval_comments` text DEFAULT NULL,
  `workflow_instance_id` int(10) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `created_by` int(10) UNSIGNED DEFAULT NULL,
  `updated_by` int(10) UNSIGNED DEFAULT NULL,
  `deleted_by` int(10) UNSIGNED DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `is_deleted` tinyint(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `change_impact_assessment`
--

CREATE TABLE `change_impact_assessment` (
  `impact_id` int(10) UNSIGNED NOT NULL,
  `change_id` int(10) UNSIGNED NOT NULL,
  `impact_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`impact_data`)),
  `risk_level` enum('LOW','MEDIUM','HIGH','CRITICAL') NOT NULL DEFAULT 'LOW',
  `severity` tinyint(3) UNSIGNED DEFAULT NULL,
  `occurrence` tinyint(3) UNSIGNED DEFAULT NULL,
  `detection` tinyint(3) UNSIGNED DEFAULT NULL,
  `rpn` int(10) UNSIGNED DEFAULT NULL,
  `summary` text DEFAULT NULL,
  `mitigation_plan` text DEFAULT NULL,
  `assessed_by` int(10) UNSIGNED DEFAULT NULL,
  `assessed_at` datetime DEFAULT NULL,
  `approval_status` enum('PENDING_APPROVAL','APPROVED','REJECTED') NOT NULL DEFAULT 'PENDING_APPROVAL',
  `approved_by` int(10) UNSIGNED DEFAULT NULL,
  `approved_at` datetime DEFAULT NULL,
  `approval_comments` text DEFAULT NULL,
  `workflow_instance_id` int(10) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `created_by` int(10) UNSIGNED DEFAULT NULL,
  `updated_by` int(10) UNSIGNED DEFAULT NULL,
  `deleted_by` int(10) UNSIGNED DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `is_deleted` tinyint(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `change_implementation_plan`
--

CREATE TABLE `change_implementation_plan` (
  `plan_id` int(10) UNSIGNED NOT NULL,
  `change_id` int(10) UNSIGNED NOT NULL,
  `step_title` varchar(255) NOT NULL,
  `step_description` text DEFAULT NULL,
  `step_order` int(10) UNSIGNED NOT NULL DEFAULT 1,
  `responsible_user_id` int(10) UNSIGNED DEFAULT NULL,
  `due_date` date DEFAULT NULL,
  `completed_date` date DEFAULT NULL,
  `status` enum('PENDING','IN_PROGRESS','COMPLETED','VERIFIED','CANCELLED') NOT NULL DEFAULT 'PENDING',
  `approval_status` enum('PENDING_APPROVAL','APPROVED','REJECTED') NOT NULL DEFAULT 'PENDING_APPROVAL',
  `approved_by` int(10) UNSIGNED DEFAULT NULL,
  `approved_at` datetime DEFAULT NULL,
  `approval_comments` text DEFAULT NULL,
  `workflow_instance_id` int(10) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `created_by` int(10) UNSIGNED DEFAULT NULL,
  `updated_by` int(10) UNSIGNED DEFAULT NULL,
  `deleted_by` int(10) UNSIGNED DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `is_deleted` tinyint(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `companies`
--

CREATE TABLE `companies` (
  `companies_id` bigint(20) UNSIGNED NOT NULL,
  `company_name` varchar(255) NOT NULL,
  `company_code` varchar(255) NOT NULL,
  `registration_number` varchar(255) DEFAULT NULL,
  `tax_number` varchar(255) DEFAULT NULL,
  `address` text DEFAULT NULL,
  `city` varchar(255) DEFAULT NULL,
  `country` varchar(255) DEFAULT NULL,
  `phone` varchar(255) DEFAULT NULL,
  `email` varchar(255) DEFAULT NULL,
  `website` varchar(255) DEFAULT NULL,
  `logo` varchar(255) DEFAULT NULL,
  `timezone` varchar(255) NOT NULL DEFAULT 'UTC',
  `currency` varchar(255) NOT NULL DEFAULT 'USD',
  `status` enum('active','inactive','suspended') NOT NULL DEFAULT 'active',
  `is_deleted` tinyint(1) NOT NULL DEFAULT 0,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `companies`
--

INSERT INTO `companies` (`companies_id`, `company_name`, `company_code`, `registration_number`, `tax_number`, `address`, `city`, `country`, `phone`, `email`, `website`, `logo`, `timezone`, `currency`, `status`, `is_deleted`, `created_by`, `updated_by`, `deleted_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'MTI Solutions', 'MTI-001', 'REG123456', 'TAX123456', 'Kampala, Uganda', 'Kampala', 'Uganda', '+256 700 000 000', 'info@mtisolutions.com', 'https://www.mtisolutons.com', NULL, 'Africa/Kampala', 'UGX', 'active', 0, NULL, NULL, NULL, '2026-09-12 06:46:58', '2026-09-12 06:46:58', NULL);

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

--
-- Table structure for table `complaints`
--

CREATE TABLE `complaints` (
  `complaint_id` bigint(20) UNSIGNED NOT NULL,
  `complaint_number` varchar(50) NOT NULL,
  `title` varchar(255) NOT NULL,
  `complaint_type` varchar(50) NOT NULL,
  `source` varchar(50) NOT NULL,
  `severity` varchar(20) NOT NULL,
  `current_status` varchar(50) NOT NULL,
  `current_phase` varchar(50) NOT NULL,
  `description` text NOT NULL,
  `customer_details` text DEFAULT NULL,
  `product_name` varchar(255) DEFAULT NULL,
  `product_lot_number` varchar(255) DEFAULT NULL,
  `incident_date` date DEFAULT NULL,
  `received_date` date NOT NULL,
  `is_reportable` tinyint(1) NOT NULL DEFAULT 0,
  `regulatory_body` varchar(100) DEFAULT NULL,
  `report_reference` varchar(100) DEFAULT NULL,
  `report_due_date` date DEFAULT NULL,
  `report_submitted_date` date DEFAULT NULL,
  `reportability_rationale` text DEFAULT NULL,
  `investigation_findings` text DEFAULT NULL,
  `root_cause` text DEFAULT NULL,
  `corrective_action` text DEFAULT NULL,
  `preventive_action` text DEFAULT NULL,
  `closure_summary` text DEFAULT NULL,
  `closed_date` date DEFAULT NULL,
  `owner_id` bigint(20) UNSIGNED DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `department_id` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `complaints`
--

INSERT INTO `complaints` (`complaint_id`, `complaint_number`, `title`, `complaint_type`, `source`, `severity`, `current_status`, `current_phase`, `description`, `customer_details`, `product_name`, `product_lot_number`, `incident_date`, `received_date`, `is_reportable`, `regulatory_body`, `report_reference`, `report_due_date`, `report_submitted_date`, `reportability_rationale`, `investigation_findings`, `root_cause`, `corrective_action`, `preventive_action`, `closure_summary`, `closed_date`, `owner_id`, `created_by`, `department_id`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'CMP-2026-0001', 'Discoloration observed in finished tablet batch', 'PRODUCT', 'CUSTOMER', 'MAJOR', 'UNDER_INVESTIGATION', 'INVESTIGATION', 'A hospital pharmacy reported that 30 tablets in lot BT-2026-0451 had a brown discoloration on the coating surface. The affected tablets were isolated before dispensing. No adverse events reported to date.', 'St. Mary\'s Regional Hospital\nPharmacy Department\nContact: Dr. A. Okello\n+256 700 000 111', 'Paracetamol 500mg Tablets', 'BT-2026-0451', '2026-08-22', '2026-08-23', 0, NULL, NULL, NULL, NULL, 'Cosmetic defect with no patient harm and no efficacy impact. Not reportable under current regulatory guidance.', 'Initial review of retained samples from lot BT-2026-0451 confirmed visual discoloration on approximately 3% of tablets. Batch manufacturing records show normal parameters. Coating suspension prepared with a new lot of Opadry from an alternate supplier.', 'Preliminary root cause points to an out-of-specification lot of coating material received from the alternate supplier. Supplier CoA review is ongoing.', 'Coating material lot quarantined pending supplier investigation.', 'Add incoming inspection step for coating materials from the alternate supplier.', NULL, NULL, 1, 1, 1, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(2, 'CMP-2026-0002', 'Wrong strength label applied to blister packs', 'SAFETY', 'INTERNAL', 'CRITICAL', 'PENDING_REPORT', 'REGULATORY', 'During routine QA review of finished goods, three blister packs of Amoxicillin 250mg were found to carry labels for the 500mg strength. The affected packs were isolated at the packing line before distribution.', NULL, 'Amoxicillin Capsules', 'AMX-2026-0088', '2026-09-03', '2026-09-04', 1, 'National Drug Authority', 'NDA/QA/2026/0912', '2026-09-18', NULL, 'Label mix-up with a different strength of a prescription medicine is a Class II recall trigger under current regulatory requirements. Formal notification is required within 15 days.', 'Investigation determined that a label roll changeover at the packing line was not verified by a second operator. Two label rolls were present on the line at the same time. The affected packs were caught by QA review before release to market.', 'Human error during label changeover — failure to follow the two-person verification procedure for label rolls.', 'Retrain packing line operators on label changeover procedure and reinstate mandatory second-operator verification.', 'Add electronic label verification at the packing line before release.', NULL, NULL, 1, 1, 1, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(3, 'CMP-2026-0003', 'Suspected adverse event following use of cough syrup', 'SAFETY', 'CUSTOMER', 'CRITICAL', 'REPORTED', 'REGULATORY', 'A pediatric patient developed a mild rash and urticaria two hours after administration of cough syrup lot CS-2026-0012. The event resolved without intervention. The mother reported the event to the pharmacy, which escalated it.', 'Community Pharmacy, Kampala\nReported by: Ms. J. Nakato, Pharmacist', 'Pediatric Cough Syrup 100ml', 'CS-2026-0012', '2026-08-13', '2026-08-15', 1, 'National Drug Authority', 'NDA/ADR/2026/0451', '2026-09-09', '2026-09-10', 'Suspected adverse drug reaction — mandatory reporting under pharmacovigilance regulations. Report submitted within the required 15-day window.', 'Retained sample analysis found no deviations. Batch records confirm correct formulation and no contamination. The patient had no known allergies on record but had never previously been exposed to this product.', 'Likely idiosyncratic hypersensitivity reaction, not a product quality defect.', NULL, NULL, NULL, NULL, 1, 1, 1, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(4, 'CMP-2026-0004', 'Shortfill observed in 5L IV solution bag', 'PRODUCT', 'DISTRIBUTOR', 'MINOR', 'CLOSED', 'CLOSURE', 'A distributor reported that one 5L bag of normal saline appeared to contain approximately 4.7L instead of the labelled 5L. The bag was returned for investigation.', 'MedSupply Distributors Ltd\nReturned goods received 2026-08-14', 'Sodium Chloride 0.9% IV Infusion 5L', 'NS-2026-0201', '2026-07-29', '2026-07-30', 0, NULL, NULL, NULL, NULL, 'No product defect identified; not reportable.', 'Weight verification of the returned bag confirmed 4.72 kg, within the ±5% fill tolerance allowed by the product specification. Review of production records showed normal fill weights. The distributor accepted the explanation.', 'Perception — fill volume was within specification.', 'None required.', 'Reinforce with distributors that bag fill weights are verified against the approved specification.', 'Investigation determined no product defect. Distributor trained on fill weight specifications. Complaint closed.', '2026-08-23', 1, 1, 1, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(5, 'CMP-2026-0005', 'Delayed delivery of temperature-sensitive shipment', 'SERVICE', 'CUSTOMER', 'MAJOR', 'LOGGED', 'INTAKE', 'A hospital reported that a shipment of insulin pens arrived 36 hours later than scheduled. The cold-chain data logger shows the shipment remained within 2–8°C throughout. No product was dispensed from the shipment pending confirmation.', 'Mulago National Referral Hospital\nReceiving Officer: Mr. P. Ssemakula', 'Insulin Glargine Pre-filled Pens', 'INS-2026-0117', '2026-09-10', '2026-09-11', 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, 1, 1, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(6, 'CMP-2026-0006', 'Foreign particulate matter in oral suspension', 'SAFETY', 'CUSTOMER', 'CRITICAL', 'UNDER_INVESTIGATION', 'INVESTIGATION', 'A caregiver reported a dark particulate visible inside a sealed bottle of amoxicillin oral suspension before first use. The bottle was returned and photographed.', 'Kampala Community Clinic\nReported by: Ms. R. Nabirye', 'Amoxicillin Oral Suspension 125mg/5ml', 'AMX-SUS-2026-0033', '2026-09-06', '2026-09-07', 1, 'National Drug Authority', NULL, '2026-09-21', NULL, 'Potential foreign particulate in a pediatric product is a serious quality defect and may trigger a recall. Assessment pending lab identification.', 'Visual inspection confirms a single dark particulate approximately 1 mm in the sealed bottle. Retained samples from the same lot have been pulled for lab analysis. FTIR identification pending.', NULL, NULL, NULL, NULL, NULL, 1, 1, 1, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL);

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

--
-- Table structure for table `complaint_audit_trails`
--

CREATE TABLE `complaint_audit_trails` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `complaint_id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `action_type` varchar(100) NOT NULL,
  `action_description` text DEFAULT NULL,
  `metadata` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`metadata`)),
  `changed_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `complaint_audit_trails`
--

INSERT INTO `complaint_audit_trails` (`id`, `complaint_id`, `user_id`, `action_type`, `action_description`, `metadata`, `changed_at`) VALUES
(1, 1, 1, 'CREATED', 'Complaint logged.', NULL, '2026-08-22 23:00:00'),
(2, 1, 1, 'STATUS_TRANSITION', 'Status changed from LOGGED to UNDER_INVESTIGATION. Reason: Assigned to investigator.', '{\"from\":\"LOGGED\",\"to\":\"UNDER_INVESTIGATION\"}', '2026-08-23 03:00:00'),
(3, 1, 1, 'INVESTIGATION_UPDATED', 'Investigation findings recorded.', NULL, '2026-08-24 21:00:00'),
(4, 2, 1, 'CREATED', 'Complaint logged.', NULL, '2026-09-03 23:00:00'),
(5, 2, 1, 'STATUS_TRANSITION', 'Status changed from LOGGED to UNDER_INVESTIGATION. Reason: Assigned to investigator.', '{\"from\":\"LOGGED\",\"to\":\"UNDER_INVESTIGATION\"}', '2026-09-04 03:00:00'),
(6, 2, 1, 'INVESTIGATION_UPDATED', 'Investigation findings recorded.', NULL, '2026-09-05 21:00:00'),
(7, 2, 1, 'REPORTABILITY_ASSESSED', 'Marked as reportable.', '{\"regulatory_body\":\"National Drug Authority\"}', '2026-09-06 21:00:00'),
(8, 3, 1, 'CREATED', 'Complaint logged.', NULL, '2026-08-14 23:00:00'),
(9, 3, 1, 'STATUS_TRANSITION', 'Status changed from LOGGED to UNDER_INVESTIGATION. Reason: Assigned to investigator.', '{\"from\":\"LOGGED\",\"to\":\"UNDER_INVESTIGATION\"}', '2026-08-15 03:00:00'),
(10, 3, 1, 'INVESTIGATION_UPDATED', 'Investigation findings recorded.', NULL, '2026-08-16 21:00:00'),
(11, 3, 1, 'REPORTABILITY_ASSESSED', 'Marked as reportable.', '{\"regulatory_body\":\"National Drug Authority\"}', '2026-08-17 21:00:00'),
(12, 3, 1, 'REPORT_SUBMITTED', 'Report submitted to National Drug Authority. Reference: NDA/ADR/2026/0451', NULL, '2026-09-09 21:00:00'),
(13, 4, 1, 'CREATED', 'Complaint logged.', NULL, '2026-07-29 23:00:00'),
(14, 4, 1, 'STATUS_TRANSITION', 'Status changed from LOGGED to UNDER_INVESTIGATION. Reason: Assigned to investigator.', '{\"from\":\"LOGGED\",\"to\":\"UNDER_INVESTIGATION\"}', '2026-07-30 03:00:00'),
(15, 4, 1, 'INVESTIGATION_UPDATED', 'Investigation findings recorded.', NULL, '2026-07-31 21:00:00'),
(16, 4, 1, 'STATUS_TRANSITION', 'Status changed from UNDER_INVESTIGATION to CLOSED.', '{\"from\":\"UNDER_INVESTIGATION\",\"to\":\"CLOSED\"}', '2026-08-22 21:00:00'),
(17, 5, 1, 'CREATED', 'Complaint logged.', NULL, '2026-09-10 23:00:00'),
(18, 5, 1, 'STATUS_TRANSITION', 'Status changed from LOGGED to UNDER_INVESTIGATION. Reason: Assigned to investigator.', '{\"from\":\"LOGGED\",\"to\":\"UNDER_INVESTIGATION\"}', '2026-09-11 03:00:00'),
(19, 6, 1, 'CREATED', 'Complaint logged.', NULL, '2026-09-06 23:00:00'),
(20, 6, 1, 'STATUS_TRANSITION', 'Status changed from LOGGED to UNDER_INVESTIGATION. Reason: Assigned to investigator.', '{\"from\":\"LOGGED\",\"to\":\"UNDER_INVESTIGATION\"}', '2026-09-07 03:00:00'),
(21, 6, 1, 'INVESTIGATION_UPDATED', 'Investigation findings recorded.', NULL, '2026-09-08 21:00:00'),
(22, 6, 1, 'REPORTABILITY_ASSESSED', 'Marked as reportable.', '{\"regulatory_body\":\"National Drug Authority\"}', '2026-09-09 21:00:00');

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

--
-- Table structure for table `complaint_links`
--

CREATE TABLE `complaint_links` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `complaint_id` bigint(20) UNSIGNED NOT NULL,
  `linked_type` varchar(100) NOT NULL,
  `linked_id` bigint(20) UNSIGNED NOT NULL,
  `relationship` varchar(50) NOT NULL,
  `impact_notes` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `complaint_links`
--

INSERT INTO `complaint_links` (`id`, `complaint_id`, `linked_type`, `linked_id`, `relationship`, `impact_notes`, `created_at`, `updated_at`) VALUES
(1, 2, 'CHANGE_CONTROL', 1, 'RESOLVED_BY', 'Corrective action tracked through change control CC-2026-0014 (electronic label verification).', '2026-09-12 06:47:00', '2026-09-12 06:47:00'),
(2, 4, 'CAPA', 1, 'RELATED_TO', 'No CAPA required — investigation concluded no defect.', '2026-09-12 06:47:00', '2026-09-12 06:47:00');

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

--
-- Table structure for table `curriculum_topics`
--

CREATE TABLE `curriculum_topics` (
  `curriculum_topic_id` bigint(20) UNSIGNED NOT NULL,
  `curriculum_id` bigint(20) UNSIGNED NOT NULL,
  `topic_id` bigint(20) UNSIGNED NOT NULL,
  `sequence_order` int(11) NOT NULL DEFAULT 0,
  `is_mandatory` tinyint(1) NOT NULL DEFAULT 1,
  `estimated_hours` decimal(5,2) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `departments`
--

CREATE TABLE `departments` (
  `department_id` bigint(20) UNSIGNED NOT NULL,
  `company_id` bigint(20) UNSIGNED NOT NULL,
  `branch_id` bigint(20) UNSIGNED NOT NULL,
  `department_code` varchar(50) NOT NULL,
  `department_name` varchar(100) NOT NULL,
  `manager_id` bigint(20) UNSIGNED DEFAULT NULL,
  `description` text DEFAULT NULL,
  `status` enum('active','inactive') NOT NULL DEFAULT 'active',
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `is_deleted` tinyint(1) NOT NULL DEFAULT 0,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `departments`
--

INSERT INTO `departments` (`department_id`, `company_id`, `branch_id`, `department_code`, `department_name`, `manager_id`, `description`, `status`, `is_active`, `is_deleted`, `created_by`, `updated_by`, `deleted_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 1, 1, 'IT', 'Information Technology', NULL, NULL, 'active', 1, 0, NULL, NULL, NULL, '2026-09-12 06:46:58', '2026-09-12 06:46:58', NULL),
(2, 1, 1, 'HR', 'Human Resources', NULL, NULL, 'active', 1, 0, NULL, NULL, NULL, '2026-09-12 06:46:58', '2026-09-12 06:46:58', NULL),
(3, 1, 1, 'QA', 'Quality Assurance', NULL, NULL, 'active', 1, 0, NULL, NULL, NULL, '2026-09-12 06:46:58', '2026-09-12 06:46:58', NULL),
(4, 1, 1, 'OPS', 'Operations', NULL, NULL, 'active', 1, 0, NULL, NULL, NULL, '2026-09-12 06:46:58', '2026-09-12 06:46:58', NULL),
(5, 1, 1, 'FIN', 'Finance', NULL, NULL, 'active', 1, 0, NULL, NULL, NULL, '2026-09-12 06:46:58', '2026-09-12 06:46:58', NULL);

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

--
-- Table structure for table `deviation_5whys`
--

CREATE TABLE `deviation_5whys` (
  `why_id` bigint(20) UNSIGNED NOT NULL,
  `root_cause_id` bigint(20) UNSIGNED NOT NULL,
  `why_level` tinyint(3) UNSIGNED NOT NULL,
  `question` text NOT NULL,
  `answer` text NOT NULL,
  `evidence` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `deviation_actions`
--

CREATE TABLE `deviation_actions` (
  `action_id` bigint(20) UNSIGNED NOT NULL,
  `deviation_id` bigint(20) UNSIGNED NOT NULL,
  `action_type` enum('IMMEDIATE_CORRECTION','CONTAINMENT','CORRECTIVE_ACTION','PREVENTIVE_ACTION') NOT NULL,
  `action_description` text NOT NULL,
  `assigned_to` bigint(20) UNSIGNED DEFAULT NULL,
  `due_date` date DEFAULT NULL,
  `completed_date` date DEFAULT NULL,
  `status` enum('PENDING','IN_PROGRESS','COMPLETED','VERIFIED','OVERDUE') NOT NULL DEFAULT 'PENDING',
  `verified_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `deviation_affected_items`
--

CREATE TABLE `deviation_affected_items` (
  `affected_id` bigint(20) UNSIGNED NOT NULL,
  `deviation_id` bigint(20) UNSIGNED NOT NULL,
  `batch_number` varchar(100) DEFAULT NULL,
  `product_code` varchar(100) DEFAULT NULL,
  `quantity_affected` decimal(15,3) DEFAULT NULL,
  `unit_of_measure` varchar(20) DEFAULT NULL,
  `disposition` enum('QUARANTINE','HOLD','RELEASED','REJECTED','REWORK') NOT NULL DEFAULT 'QUARANTINE',
  `disposition_date` date DEFAULT NULL,
  `disposition_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `deviation_assessments`
--

CREATE TABLE `deviation_assessments` (
  `assessment_id` bigint(20) UNSIGNED NOT NULL,
  `deviation_id` bigint(20) UNSIGNED NOT NULL,
  `severity` tinyint(3) UNSIGNED NOT NULL,
  `occurrence` tinyint(3) UNSIGNED NOT NULL,
  `detection` tinyint(3) UNSIGNED NOT NULL,
  `rpn` int(10) UNSIGNED GENERATED ALWAYS AS (`severity` * `occurrence` * `detection`) STORED,
  `risk_priority` enum('LOW','MEDIUM','HIGH','CRITICAL') DEFAULT NULL,
  `classification` enum('INCIDENT','MINOR','MAJOR','CRITICAL') DEFAULT NULL,
  `investigation_level` enum('NONE','BASIC','STANDARD','EXTENDED') DEFAULT NULL,
  `assessment_notes` text DEFAULT NULL,
  `assessed_by` bigint(20) UNSIGNED DEFAULT NULL,
  `assessment_date` datetime DEFAULT NULL,
  `approved_by` bigint(20) UNSIGNED DEFAULT NULL,
  `approved_at` datetime DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `deviation_audit_trails`
--

CREATE TABLE `deviation_audit_trails` (
  `audit_id` bigint(20) UNSIGNED NOT NULL,
  `deviation_id` bigint(20) UNSIGNED NOT NULL,
  `table_name` varchar(100) NOT NULL,
  `field_name` varchar(100) NOT NULL,
  `old_value` text DEFAULT NULL,
  `new_value` text DEFAULT NULL,
  `changed_by` bigint(20) UNSIGNED DEFAULT NULL,
  `change_reason` text DEFAULT NULL,
  `changed_at` datetime NOT NULL DEFAULT current_timestamp(),
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `deviation_capa_linkages`
--

CREATE TABLE `deviation_capa_linkages` (
  `linkage_id` bigint(20) UNSIGNED NOT NULL,
  `deviation_id` bigint(20) UNSIGNED NOT NULL,
  `capa_id` bigint(20) UNSIGNED NOT NULL,
  `linkage_type` enum('PRIMARY','SECONDARY','SUPPORTING') NOT NULL DEFAULT 'PRIMARY',
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `linked_by` bigint(20) UNSIGNED DEFAULT NULL,
  `linked_date` datetime NOT NULL DEFAULT current_timestamp(),
  `approval_instance_id` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `deviation_closures`
--

CREATE TABLE `deviation_closures` (
  `closure_id` bigint(20) UNSIGNED NOT NULL,
  `deviation_id` bigint(20) UNSIGNED NOT NULL,
  `closure_justification` text NOT NULL,
  `closure_date` date NOT NULL,
  `closure_approved_by` bigint(20) UNSIGNED DEFAULT NULL,
  `closure_notes` text DEFAULT NULL,
  `final_status` enum('CLOSED','CLOSED_EFFECTIVE','CLOSED_INEFFECTIVE') NOT NULL DEFAULT 'CLOSED',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `deviation_containments`
--

CREATE TABLE `deviation_containments` (
  `containment_id` bigint(20) UNSIGNED NOT NULL,
  `deviation_id` bigint(20) UNSIGNED NOT NULL,
  `action_type` enum('IMMEDIATE_CORRECTION','CONTAINMENT','ISOLATION','PROCESS_STOP') NOT NULL,
  `action_description` text NOT NULL,
  `taken_by` bigint(20) UNSIGNED DEFAULT NULL,
  `action_date` datetime NOT NULL,
  `effectiveness` enum('FULLY_EFFECTIVE','PARTIALLY_EFFECTIVE','NOT_EFFECTIVE') NOT NULL DEFAULT 'FULLY_EFFECTIVE',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `deviation_evidences`
--

CREATE TABLE `deviation_evidences` (
  `evidence_id` bigint(20) UNSIGNED NOT NULL,
  `deviation_id` bigint(20) UNSIGNED NOT NULL,
  `evidence_type` enum('PHOTO','VIDEO','DATA_PRINTOUT','EQUIPMENT_LOG','BATCH_RECORD','EMAIL','OTHER') NOT NULL,
  `file_name` varchar(255) NOT NULL,
  `file_path` varchar(500) NOT NULL,
  `file_size` bigint(20) UNSIGNED DEFAULT NULL,
  `uploaded_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `deviation_findings`
--

CREATE TABLE `deviation_findings` (
  `finding_id` bigint(20) UNSIGNED NOT NULL,
  `investigation_id` bigint(20) UNSIGNED NOT NULL,
  `finding_type` enum('ROOT_CAUSE','IMMEDIATE_CAUSE','CONTRIBUTING_FACTOR','OBSERVATION','DATA_ANALYSIS','INTERVIEW','TEST_RESULT','DOCUMENT_REVIEW') NOT NULL,
  `finding_description` text NOT NULL,
  `evidence_reference` text DEFAULT NULL,
  `related_to_root_cause` tinyint(1) NOT NULL DEFAULT 0,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `deviation_impacts`
--

CREATE TABLE `deviation_impacts` (
  `impact_id` bigint(20) UNSIGNED NOT NULL,
  `deviation_id` bigint(20) UNSIGNED NOT NULL,
  `impact_type` enum('PRODUCT_QUALITY','PATIENT_SAFETY','DATA_INTEGRITY','REGULATORY','BUSINESS','REPUTATIONAL','OPERATIONAL','FINANCIAL','ENVIRONMENTAL','OTHER') NOT NULL,
  `severity_level` enum('LOW','MEDIUM','HIGH','CRITICAL') NOT NULL,
  `impact_description` text DEFAULT NULL,
  `mitigation_required` tinyint(1) NOT NULL DEFAULT 0,
  `assessed_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `deviation_impact_items`
--

CREATE TABLE `deviation_impact_items` (
  `item_id` bigint(20) UNSIGNED NOT NULL,
  `impact_id` bigint(20) UNSIGNED NOT NULL,
  `impact_type` varchar(100) DEFAULT NULL,
  `impact_description` text DEFAULT NULL,
  `severity` enum('LOW','MEDIUM','HIGH','CRITICAL') NOT NULL,
  `requires_mitigation` tinyint(1) NOT NULL DEFAULT 0,
  `proposed_mitigation` text DEFAULT NULL,
  `target_date` date DEFAULT NULL,
  `mitigation_status` enum('NOT_STARTED','PLANNED','IN_PROGRESS','COMPLETED','VERIFIED','CANCELLED','OVERDUE') NOT NULL DEFAULT 'NOT_STARTED',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `deviation_investigations`
--

CREATE TABLE `deviation_investigations` (
  `investigation_id` bigint(20) UNSIGNED NOT NULL,
  `deviation_id` bigint(20) UNSIGNED NOT NULL,
  `investigation_owner` bigint(20) UNSIGNED DEFAULT NULL,
  `methodology` enum('5_WHYS','FISHBONE','FMEA','PROCESS_MAPPING','DATA_ANALYSIS','COMBINATION') DEFAULT NULL,
  `team_members` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`team_members`)),
  `investigation_plan` text DEFAULT NULL,
  `start_date` date DEFAULT NULL,
  `due_date` date DEFAULT NULL,
  `actual_completion_date` date DEFAULT NULL,
  `conclusion` text DEFAULT NULL,
  `status` enum('PLANNED','IN_PROGRESS','COMPLETED','DELAYED') NOT NULL DEFAULT 'PLANNED',
  `workflow_instance_id` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `deviation_masters`
--

CREATE TABLE `deviation_masters` (
  `deviation_id` bigint(20) UNSIGNED NOT NULL,
  `deviation_number` varchar(50) NOT NULL,
  `record_kind` enum('DEVIATION','NONCONFORMANCE') NOT NULL DEFAULT 'DEVIATION',
  `title` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `deviation_type` varchar(100) NOT NULL,
  `deviation_category` enum('PLANNED','UNPLANNED') NOT NULL,
  `is_emergency` tinyint(1) NOT NULL DEFAULT 0,
  `department_id` bigint(20) UNSIGNED NOT NULL,
  `discovered_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `location` varchar(255) DEFAULT NULL,
  `process_step` varchar(255) DEFAULT NULL,
  `discovered_date` datetime NOT NULL,
  `planned_start_date` date DEFAULT NULL,
  `planned_end_date` date DEFAULT NULL,
  `status` enum('DRAFT','SUBMITTED','UNDER_REVIEW','UNDER_INVESTIGATION','AWAITING_CAPA','AWAITING_CLOSURE','CLOSED','REJECTED') NOT NULL DEFAULT 'DRAFT',
  `current_phase` tinyint(3) UNSIGNED NOT NULL DEFAULT 1,
  `workflow_instance_id` bigint(20) UNSIGNED DEFAULT NULL,
  `capa_initiated` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `deviation_root_causes`
--

CREATE TABLE `deviation_root_causes` (
  `root_cause_id` bigint(20) UNSIGNED NOT NULL,
  `investigation_id` bigint(20) UNSIGNED NOT NULL,
  `root_cause_type` enum('EQUIPMENT','PROCESS','PERSONNEL','MATERIAL','ENVIRONMENT','METHOD','MEASUREMENT','MANAGEMENT') NOT NULL,
  `root_cause_description` text NOT NULL,
  `is_systemic` tinyint(1) NOT NULL DEFAULT 0,
  `evidence_references` text DEFAULT NULL,
  `confirmed_by` bigint(20) UNSIGNED DEFAULT NULL,
  `confirmed_date` datetime DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `documents`
--

CREATE TABLE `documents` (
  `document_id` bigint(20) UNSIGNED NOT NULL,
  `source_id` int(11) DEFAULT NULL COMMENT 'ID from source table',
  `workflow_id` bigint(20) UNSIGNED DEFAULT NULL,
  `workflow_instance_id` bigint(20) UNSIGNED DEFAULT NULL,
  `current_version_id` bigint(20) UNSIGNED DEFAULT NULL,
  `source_type` varchar(500) NOT NULL,
  `document_code` varchar(50) NOT NULL,
  `document_title` varchar(500) DEFAULT NULL,
  `document_type` varchar(255) NOT NULL,
  `version_number` varchar(10) NOT NULL DEFAULT '1.0',
  `document_status` enum('Draft','Under Review','Approved','Archived','Rejected','Request_Changes') NOT NULL DEFAULT 'Draft',
  `training_status` enum('Pending','Completed') NOT NULL DEFAULT 'Pending',
  `description` text DEFAULT NULL,
  `effective_date` date DEFAULT NULL,
  `review_date` date DEFAULT NULL,
  `file_path` varchar(255) DEFAULT NULL,
  `word_document_id` varchar(100) DEFAULT NULL,
  `review_mode` varchar(50) NOT NULL DEFAULT 'form',
  `approval_flow` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`approval_flow`)),
  `change_tracking_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`change_tracking_data`)),
  `is_deleted` tinyint(1) NOT NULL DEFAULT 0,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `archived_at` timestamp NULL DEFAULT NULL,
  `signed_by` bigint(20) UNSIGNED DEFAULT NULL,
  `signed_at` timestamp NULL DEFAULT NULL,
  `signature_hash` varchar(255) DEFAULT NULL,
  `signature_ip` varchar(45) DEFAULT NULL,
  `signature_user_agent` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `documents`
--

INSERT INTO `documents` (`document_id`, `source_id`, `workflow_id`, `workflow_instance_id`, `current_version_id`, `source_type`, `document_code`, `document_title`, `document_type`, `version_number`, `document_status`, `training_status`, `description`, `effective_date`, `review_date`, `file_path`, `word_document_id`, `review_mode`, `approval_flow`, `change_tracking_data`, `is_deleted`, `created_by`, `updated_by`, `deleted_by`, `created_at`, `updated_at`, `deleted_at`, `archived_at`, `signed_by`, `signed_at`, `signature_hash`, `signature_ip`, `signature_user_agent`) VALUES
(1, 1, NULL, NULL, 1, 'sop', 'DOC/2026/0001', 'Sample Document 1', 'SOP', '03', 'Draft', 'Pending', NULL, NULL, NULL, NULL, NULL, 'form', NULL, NULL, 0, 1, NULL, NULL, '2026-08-14 06:46:59', '2026-09-12 06:46:59', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(2, 2, NULL, NULL, 2, 'sop', 'DOC/2026/0002', 'Sample Document 2', 'Report', '02', 'Archived', 'Pending', NULL, NULL, NULL, NULL, NULL, 'form', NULL, NULL, 0, 1, NULL, NULL, '2026-08-28 06:46:59', '2026-09-12 06:46:59', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(3, 3, NULL, NULL, 3, 'sop', 'DOC/2026/0003', 'Sample Document 3', 'Form', '05', 'Approved', 'Pending', NULL, NULL, NULL, NULL, NULL, 'form', NULL, NULL, 0, 1, NULL, NULL, '2026-08-13 06:46:59', '2026-09-12 06:46:59', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(4, 4, NULL, NULL, 4, 'cs', 'DOC/2026/0004', 'Sample Document 4', 'Report', '01', 'Archived', 'Pending', NULL, NULL, NULL, NULL, NULL, 'form', NULL, NULL, 0, 2, NULL, NULL, '2026-09-10 06:46:59', '2026-09-12 06:46:59', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(5, 5, NULL, NULL, 5, 'cs', 'DOC/2026/0005', 'Sample Document 5', 'Procedure', '01', 'Rejected', 'Pending', NULL, NULL, NULL, NULL, NULL, 'form', NULL, NULL, 0, 5, NULL, NULL, '2026-09-08 06:46:59', '2026-09-12 06:46:59', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(6, 6, NULL, NULL, 6, 'usv', 'DOC/2026/0006', 'Sample Document 6', 'Report', '02', 'Rejected', 'Pending', NULL, NULL, NULL, NULL, NULL, 'form', NULL, NULL, 0, 4, NULL, NULL, '2026-08-21 06:46:59', '2026-09-12 06:46:59', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(7, 7, NULL, NULL, 7, 'sop', 'DOC/2026/0007', 'Sample Document 7', 'Policy', '02', 'Draft', 'Pending', NULL, NULL, NULL, NULL, NULL, 'form', NULL, NULL, 0, 2, NULL, NULL, '2026-08-24 06:46:59', '2026-09-12 06:46:59', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(8, 8, NULL, NULL, 8, 'sop', 'DOC/2026/0008', 'Sample Document 8', 'Policy', '03', 'Archived', 'Pending', NULL, NULL, NULL, NULL, NULL, 'form', NULL, NULL, 0, 1, NULL, NULL, '2026-08-15 06:46:59', '2026-09-12 06:46:59', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(9, 9, NULL, NULL, 9, 'sop', 'DOC/2026/0009', 'Sample Document 9', 'Procedure', '01', 'Archived', 'Pending', NULL, NULL, NULL, NULL, NULL, 'form', NULL, NULL, 0, 4, NULL, NULL, '2026-08-13 06:46:59', '2026-09-12 06:46:59', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(10, 10, NULL, NULL, 10, 'usv', 'DOC/2026/0010', 'Sample Document 10', 'Procedure', '04', 'Under Review', 'Pending', NULL, NULL, NULL, NULL, NULL, 'form', NULL, NULL, 0, 4, NULL, NULL, '2026-08-31 06:46:59', '2026-09-12 06:46:59', NULL, NULL, NULL, NULL, NULL, NULL, NULL);

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

--
-- Table structure for table `document_acknowledgements`
--

CREATE TABLE `document_acknowledgements` (
  `document_acknowledgements_id` bigint(20) UNSIGNED NOT NULL,
  `document_distribution_id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `acknowledged_at` timestamp NULL DEFAULT NULL,
  `comments` text DEFAULT NULL,
  `status` enum('pending','acknowledged','overdue','declined') NOT NULL DEFAULT 'pending',
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `is_deleted` tinyint(1) NOT NULL DEFAULT 0,
  `ip_address` varchar(45) DEFAULT NULL,
  `user_agent` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `document_acknowledgements`
--

INSERT INTO `document_acknowledgements` (`document_acknowledgements_id`, `document_distribution_id`, `user_id`, `acknowledged_at`, `comments`, `status`, `created_by`, `updated_by`, `deleted_by`, `created_at`, `updated_at`, `deleted_at`, `is_deleted`, `ip_address`, `user_agent`) VALUES
(1, 3, 5, '2026-09-09 06:46:59', 'Sample acknowledgement comment', 'pending', 3, NULL, NULL, '2026-09-08 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.43', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(2, 6, 3, '2026-09-10 06:46:59', 'Sample acknowledgement comment', 'overdue', 3, NULL, NULL, '2026-09-07 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.147', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(3, 5, 2, '2026-09-10 06:46:59', 'Sample acknowledgement comment', 'acknowledged', 5, NULL, NULL, '2026-09-10 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.59', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(4, 1, 5, NULL, 'Sample acknowledgement comment', 'overdue', 1, NULL, NULL, '2026-09-05 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.174', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(5, 4, 3, NULL, 'Sample acknowledgement comment', 'acknowledged', 3, NULL, NULL, '2026-09-11 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.108', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(6, 8, 5, '2026-09-07 06:46:59', 'Sample acknowledgement comment', 'declined', 5, NULL, NULL, '2026-09-08 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.144', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(7, 9, 2, NULL, 'Sample acknowledgement comment', 'declined', 1, NULL, NULL, '2026-09-09 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.146', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(8, 10, 4, '2026-09-08 06:46:59', 'Sample acknowledgement comment', 'pending', 5, NULL, NULL, '2026-09-08 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.21', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(9, 2, 4, NULL, 'Sample acknowledgement comment', 'overdue', 1, NULL, NULL, '2026-09-11 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.162', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(10, 7, 2, NULL, 'Sample acknowledgement comment', 'declined', 2, NULL, NULL, '2026-09-09 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.145', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36');

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

--
-- Table structure for table `document_distributions`
--

CREATE TABLE `document_distributions` (
  `document_distributions_id` bigint(20) UNSIGNED NOT NULL,
  `document_id` bigint(20) UNSIGNED NOT NULL,
  `document_version_id` bigint(20) UNSIGNED NOT NULL,
  `department_id` bigint(20) UNSIGNED DEFAULT NULL,
  `user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `distributed_at` timestamp NULL DEFAULT NULL,
  `acknowledgement_required` tinyint(1) NOT NULL DEFAULT 1,
  `status` enum('pending','delivered','acknowledged','expired','cancelled') NOT NULL DEFAULT 'pending',
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `is_deleted` tinyint(1) NOT NULL DEFAULT 0,
  `ip_address` varchar(45) DEFAULT NULL,
  `user_agent` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `document_distributions`
--

INSERT INTO `document_distributions` (`document_distributions_id`, `document_id`, `document_version_id`, `department_id`, `user_id`, `distributed_at`, `acknowledgement_required`, `status`, `created_by`, `updated_by`, `deleted_by`, `created_at`, `updated_at`, `deleted_at`, `is_deleted`, `ip_address`, `user_agent`) VALUES
(1, 1, 2, 3, 4, '2026-09-09 06:46:59', 1, 'expired', 5, NULL, NULL, '2026-09-08 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.126', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(2, 2, 7, 5, 1, '2026-09-03 06:46:59', 0, 'cancelled', 1, NULL, NULL, '2026-09-09 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.58', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(3, 3, 10, 1, 3, '2026-09-04 06:46:59', 0, 'pending', 2, NULL, NULL, '2026-09-04 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.95', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(4, 4, 7, 5, 2, '2026-09-07 06:46:59', 0, 'expired', 4, NULL, NULL, '2026-09-05 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.104', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(5, 5, 6, 5, 5, '2026-09-09 06:46:59', 0, 'acknowledged', 1, NULL, NULL, '2026-09-10 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.30', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(6, 6, 4, 3, 4, '2026-09-05 06:46:59', 1, 'delivered', 4, NULL, NULL, '2026-09-02 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.92', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(7, 7, 6, 3, 4, '2026-09-06 06:46:59', 0, 'cancelled', 4, NULL, NULL, '2026-09-07 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.117', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(8, 8, 4, 5, 1, '2026-09-11 06:46:59', 0, 'expired', 3, NULL, NULL, '2026-09-05 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.84', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(9, 9, 8, 3, 5, '2026-09-02 06:46:59', 0, 'expired', 1, NULL, NULL, '2026-09-06 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.95', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(10, 10, 9, 4, 1, '2026-09-10 06:46:59', 0, 'expired', 3, NULL, NULL, '2026-09-06 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.118', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36');

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

--
-- Table structure for table `document_reviews`
--

CREATE TABLE `document_reviews` (
  `document_reviews_id` bigint(20) UNSIGNED NOT NULL,
  `document_version_id` bigint(20) UNSIGNED NOT NULL,
  `reviewer_id` bigint(20) UNSIGNED NOT NULL,
  `review_date` date NOT NULL,
  `review_status` enum('pending','in_progress','completed','overdue','cancelled') NOT NULL DEFAULT 'pending',
  `comments` text DEFAULT NULL,
  `recommendation` text DEFAULT NULL,
  `recommendation_type` enum('approve','reject','modify','no_change') DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `is_deleted` tinyint(1) NOT NULL DEFAULT 0,
  `ip_address` varchar(45) DEFAULT NULL,
  `user_agent` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `document_reviews`
--

INSERT INTO `document_reviews` (`document_reviews_id`, `document_version_id`, `reviewer_id`, `review_date`, `review_status`, `comments`, `recommendation`, `recommendation_type`, `created_by`, `updated_by`, `deleted_by`, `created_at`, `updated_at`, `deleted_at`, `is_deleted`, `ip_address`, `user_agent`) VALUES
(1, 8, 2, '2026-09-22', 'in_progress', 'Sample review comment', 'Sample recommendation', 'reject', 3, NULL, NULL, '2026-08-31 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.74', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(2, 2, 3, '2026-09-21', 'in_progress', 'Sample review comment', 'Sample recommendation', 'approve', 5, NULL, NULL, '2026-08-30 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.26', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(3, 6, 4, '2026-09-30', 'overdue', 'Sample review comment', 'Sample recommendation', 'modify', 5, NULL, NULL, '2026-08-28 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.40', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(4, 4, 3, '2026-10-03', 'cancelled', 'Sample review comment', 'Sample recommendation', 'approve', 4, NULL, NULL, '2026-08-31 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.104', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(5, 7, 5, '2026-09-19', 'pending', 'Sample review comment', 'Sample recommendation', 'reject', 5, NULL, NULL, '2026-08-29 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.232', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(6, 9, 4, '2026-10-03', 'pending', 'Sample review comment', 'Sample recommendation', 'no_change', 1, NULL, NULL, '2026-09-03 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.80', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(7, 10, 5, '2026-09-22', 'cancelled', 'Sample review comment', 'Sample recommendation', 'no_change', 4, NULL, NULL, '2026-09-10 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.57', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(8, 1, 2, '2026-09-22', 'overdue', 'Sample review comment', 'Sample recommendation', 'modify', 4, NULL, NULL, '2026-08-28 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.141', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(9, 3, 4, '2026-10-06', 'in_progress', 'Sample review comment', 'Sample recommendation', 'no_change', 1, NULL, NULL, '2026-09-10 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.135', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(10, 5, 1, '2026-10-10', 'cancelled', 'Sample review comment', 'Sample recommendation', 'modify', 2, NULL, NULL, '2026-09-03 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.132', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36');

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

--
-- Table structure for table `document_versions`
--

CREATE TABLE `document_versions` (
  `document_versions_id` bigint(20) UNSIGNED NOT NULL,
  `document_id` bigint(20) UNSIGNED NOT NULL,
  `version_number` varchar(20) NOT NULL,
  `revision_number` varchar(20) DEFAULT NULL,
  `file_name` varchar(255) NOT NULL,
  `file_path` varchar(255) NOT NULL,
  `file_type` varchar(50) NOT NULL,
  `file_size` bigint(20) UNSIGNED DEFAULT NULL,
  `change_summary` text DEFAULT NULL,
  `change_reason` text DEFAULT NULL,
  `prepared_by` bigint(20) UNSIGNED DEFAULT NULL,
  `reviewed_by` bigint(20) UNSIGNED DEFAULT NULL,
  `approved_by` bigint(20) UNSIGNED DEFAULT NULL,
  `effective_date` date DEFAULT NULL,
  `status` enum('draft','under_review','approved','obsolete','archived') NOT NULL DEFAULT 'draft',
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `is_deleted` tinyint(1) NOT NULL DEFAULT 0,
  `ip_address` varchar(45) DEFAULT NULL,
  `user_agent` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `document_versions`
--

INSERT INTO `document_versions` (`document_versions_id`, `document_id`, `version_number`, `revision_number`, `file_name`, `file_path`, `file_type`, `file_size`, `change_summary`, `change_reason`, `prepared_by`, `reviewed_by`, `approved_by`, `effective_date`, `status`, `created_by`, `updated_by`, `deleted_by`, `created_at`, `updated_at`, `deleted_at`, `is_deleted`, `ip_address`, `user_agent`) VALUES
(1, 1, '1.07', 'Rev 0', 'sample_document_1.pdf', 'documents/sample_document_1.pdf', 'pdf', 4404511, 'Initial version of sample document', 'Document creation', 3, 4, 3, '2026-10-07', 'obsolete', 5, NULL, NULL, '2026-09-11 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.216', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(2, 2, '1.02', 'Rev 3', 'sample_document_2.pdf', 'documents/sample_document_2.pdf', 'pdf', 2850189, 'Initial version of sample document', 'Document creation', 3, 1, 5, '2026-09-27', 'under_review', 1, NULL, NULL, '2026-08-25 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.11', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(3, 3, '1.02', 'Rev 3', 'sample_document_3.pdf', 'documents/sample_document_3.pdf', 'pdf', 6354972, 'Initial version of sample document', 'Document creation', 5, 2, 3, '2026-10-03', 'obsolete', 2, NULL, NULL, '2026-09-11 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.125', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(4, 4, '1.04', 'Rev 4', 'sample_document_4.pdf', 'documents/sample_document_4.pdf', 'pdf', 10035976, 'Initial version of sample document', 'Document creation', 2, 1, 4, '2026-10-09', 'approved', 5, NULL, NULL, '2026-09-09 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.203', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(5, 5, '1.00', 'Rev 0', 'sample_document_5.pdf', 'documents/sample_document_5.pdf', 'pdf', 5508579, 'Initial version of sample document', 'Document creation', 5, 2, 4, '2026-10-06', 'archived', 2, NULL, NULL, '2026-09-05 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.188', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(6, 6, '1.01', 'Rev 5', 'sample_document_6.pdf', 'documents/sample_document_6.pdf', 'pdf', 3225849, 'Initial version of sample document', 'Document creation', 2, 1, 2, '2026-09-25', 'under_review', 1, NULL, NULL, '2026-08-29 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.99', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(7, 7, '1.00', 'Rev 4', 'sample_document_7.pdf', 'documents/sample_document_7.pdf', 'pdf', 2341890, 'Initial version of sample document', 'Document creation', 2, 4, 3, '2026-09-30', 'approved', 4, NULL, NULL, '2026-08-29 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.56', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(8, 8, '1.07', 'Rev 0', 'sample_document_8.pdf', 'documents/sample_document_8.pdf', 'pdf', 832867, 'Initial version of sample document', 'Document creation', 3, 5, 1, '2026-09-25', 'draft', 5, NULL, NULL, '2026-09-03 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.127', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(9, 9, '1.06', 'Rev 0', 'sample_document_9.pdf', 'documents/sample_document_9.pdf', 'pdf', 2946467, 'Initial version of sample document', 'Document creation', 4, 1, 2, '2026-09-20', 'approved', 4, NULL, NULL, '2026-09-04 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.108', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
(10, 10, '1.09', 'Rev 0', 'sample_document_10.pdf', 'documents/sample_document_10.pdf', 'pdf', 7150459, 'Initial version of sample document', 'Document creation', 1, 4, 3, '2026-09-30', 'approved', 5, NULL, NULL, '2026-09-10 06:46:59', '2026-09-12 06:46:59', NULL, 0, '192.168.1.215', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36');

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

--
-- Table structure for table `electronic_signatures`
--

CREATE TABLE `electronic_signatures` (
  `electronic_signatures_id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `module_id` bigint(20) UNSIGNED DEFAULT NULL,
  `record_id` bigint(20) UNSIGNED DEFAULT NULL,
  `signature_type` varchar(255) NOT NULL,
  `signature_meaning` text DEFAULT NULL,
  `signed_at` timestamp NULL DEFAULT NULL,
  `ip_address` varchar(45) DEFAULT NULL,
  `verification_method` varchar(255) NOT NULL DEFAULT 'password',
  `signature_status` enum('valid','invalid','revoked','expired') NOT NULL DEFAULT 'valid',
  `reason` text DEFAULT NULL,
  `signature_image_path` varchar(255) DEFAULT NULL,
  `signature_hash` text DEFAULT NULL,
  `signature_user_agent` varchar(255) DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `is_deleted` tinyint(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `electronic_signatures`
--

INSERT INTO `electronic_signatures` (`electronic_signatures_id`, `user_id`, `module_id`, `record_id`, `signature_type`, `signature_meaning`, `signed_at`, `ip_address`, `verification_method`, `signature_status`, `reason`, `signature_image_path`, `signature_hash`, `signature_user_agent`, `created_by`, `updated_by`, `deleted_by`, `created_at`, `updated_at`, `deleted_at`, `is_deleted`) VALUES
(1, 2, 7, 5, 'review', 'I agree to the terms of this document', '2026-09-03 06:46:59', '192.168.1.61', 'password', 'revoked', 'Sample signature reason', NULL, 'fe8458a950cb809ffac4b8bd4721926be4587025e79a18c538bd8a42fd893180', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 2, NULL, NULL, '2026-09-05 06:46:59', '2026-09-12 06:46:59', NULL, 0),
(2, 4, 2, 12, 'authorize', 'I agree to the terms of this document', '2026-09-10 06:46:59', '192.168.1.95', 'password', 'expired', 'Sample signature reason', NULL, '9f48cfe479aeda3741141a12b81a530b5f8c84494d6d4133f5c2f6199a93ed4c', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 4, NULL, NULL, '2026-09-02 06:46:59', '2026-09-12 06:46:59', NULL, 0),
(3, 3, 3, 15, 'approve', 'I agree to the terms of this document', '2026-09-04 06:46:59', '192.168.1.59', 'password', 'valid', 'Sample signature reason', NULL, '75107caf15855a415d0afd00d71be285e04d182fe7fafef86c80e48063729d9c', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 3, NULL, NULL, '2026-09-02 06:46:59', '2026-09-12 06:46:59', NULL, 0),
(4, 2, 3, 1, 'reject', 'I agree to the terms of this document', '2026-09-02 06:46:59', '192.168.1.163', 'password', 'invalid', 'Sample signature reason', NULL, '74add4c47da5a6faf07724dc0bef9134181371919f3e4805a4b3b73b7ee7e6ba', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 2, NULL, NULL, '2026-09-11 06:46:59', '2026-09-12 06:46:59', NULL, 0),
(5, 1, 10, 16, 'approve', 'I agree to the terms of this document', '2026-09-05 06:46:59', '192.168.1.66', 'password', 'invalid', 'Sample signature reason', NULL, '8f4e72dbb41c8653600607ba02e5957ba1d9a1ae34f7ee9d70dab7f3e85ae161', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 1, NULL, NULL, '2026-09-11 06:46:59', '2026-09-12 06:46:59', NULL, 0),
(6, 5, 8, 11, 'acknowledge', 'I agree to the terms of this document', '2026-09-11 06:46:59', '192.168.1.246', 'password', 'revoked', 'Sample signature reason', NULL, 'b301c87f6cbb0cfcad7926c26fc8a4411e581203415828378fb787018808dca2', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 5, NULL, NULL, '2026-09-10 06:46:59', '2026-09-12 06:46:59', NULL, 0),
(7, 1, 13, 4, 'authorize', 'I agree to the terms of this document', '2026-09-11 06:46:59', '192.168.1.67', 'password', 'revoked', 'Sample signature reason', NULL, '51ba482d0df6679d342c804e6a1d05f5be9b3a30098e91685c355a3782e7ed99', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 1, NULL, NULL, '2026-09-10 06:46:59', '2026-09-12 06:46:59', NULL, 0),
(8, 3, 10, 10, 'reject', 'I agree to the terms of this document', '2026-09-11 06:46:59', '192.168.1.225', 'password', 'revoked', 'Sample signature reason', NULL, '1c6c8b717d892707f57999e7412894efc2130fe8b80da4de7fa2897462e46f33', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 3, NULL, NULL, '2026-09-02 06:46:59', '2026-09-12 06:46:59', NULL, 0),
(9, 1, 12, 14, 'reject', 'I agree to the terms of this document', '2026-09-06 06:46:59', '192.168.1.142', 'password', 'valid', 'Sample signature reason', NULL, 'c836d64513288e7fd9be93fdaa9d6440666d0d0e073bec2a8e7c16b0b0fb6e1e', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 1, NULL, NULL, '2026-09-02 06:46:59', '2026-09-12 06:46:59', NULL, 0),
(10, 1, 6, 17, 'reject', 'I agree to the terms of this document', '2026-09-10 06:46:59', '192.168.1.130', 'password', 'valid', 'Sample signature reason', NULL, 'e7ff3334e9752d4d09e1e0a18383f506d96aa97c0a0051a91a26aa8e337e4681', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 1, NULL, NULL, '2026-09-07 06:46:59', '2026-09-12 06:46:59', NULL, 0),
(11, 4, 9, 9, 'review', 'I agree to the terms of this document', '2026-09-02 06:46:59', '192.168.1.242', 'password', 'invalid', 'Sample signature reason', NULL, '4a99fffbb04ed0c2323a791e0f7d23baf26d2ab20456089f8dafbd12325663cd', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 4, NULL, NULL, '2026-09-07 06:46:59', '2026-09-12 06:46:59', NULL, 0),
(12, 5, 9, 7, 'review', 'I agree to the terms of this document', '2026-09-04 06:46:59', '192.168.1.168', 'password', 'expired', 'Sample signature reason', NULL, '516fd3aa650ed38ef5538045965f3d274d415cc88bab50a32cfa6fd28fa0d552', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 5, NULL, NULL, '2026-09-07 06:46:59', '2026-09-12 06:46:59', NULL, 0),
(13, 3, 3, 9, 'authorize', 'I agree to the terms of this document', '2026-09-03 06:46:59', '192.168.1.120', 'password', 'expired', 'Sample signature reason', NULL, '466ae00dd71836e2388485be482ed2dc6e0a78097d5c6d9799d7c3a6b3f25b4b', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 3, NULL, NULL, '2026-09-10 06:46:59', '2026-09-12 06:46:59', NULL, 0),
(14, 2, 6, 4, 'reject', 'I agree to the terms of this document', '2026-09-04 06:46:59', '192.168.1.98', 'password', 'valid', 'Sample signature reason', NULL, '3524716b2888767e79174d5e9982e60a7c0c48203121a4296e9ba7f390f31685', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 2, NULL, NULL, '2026-09-08 06:46:59', '2026-09-12 06:46:59', NULL, 0),
(15, 2, 7, 14, 'acknowledge', 'I agree to the terms of this document', '2026-09-03 06:46:59', '192.168.1.85', 'password', 'invalid', 'Sample signature reason', NULL, '40143af2d342da9aaf99bd81ffd355efbccc13f3e1d88b8bcf3e0591e4ca5c2d', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 2, NULL, NULL, '2026-09-11 06:46:59', '2026-09-12 06:46:59', NULL, 0),
(16, 3, 3, 3, 'review', 'I agree to the terms of this document', '2026-09-08 06:46:59', '192.168.1.217', 'password', 'revoked', 'Sample signature reason', NULL, 'ca591827d0d5f8ff85199353a97751cc0cbebf0893ba57007ea9d86858d4c009', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 3, NULL, NULL, '2026-09-08 06:46:59', '2026-09-12 06:46:59', NULL, 0),
(17, 5, 6, 3, 'reject', 'I agree to the terms of this document', '2026-09-07 06:46:59', '192.168.1.15', 'password', 'revoked', 'Sample signature reason', NULL, '012aa98dbcdbaea2b3a3488a569b13df61b48fb372a2491314268eada761ec62', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 5, NULL, NULL, '2026-09-02 06:46:59', '2026-09-12 06:46:59', NULL, 0),
(18, 2, 7, 13, 'review', 'I agree to the terms of this document', '2026-09-08 06:46:59', '192.168.1.243', 'password', 'expired', 'Sample signature reason', NULL, '020944bba84b78d70082e94d6d22f1bbf89ce06611c9662a7dab7cd060eee4f5', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 2, NULL, NULL, '2026-09-10 06:46:59', '2026-09-12 06:46:59', NULL, 0),
(19, 5, 5, 8, 'review', 'I agree to the terms of this document', '2026-09-07 06:46:59', '192.168.1.33', 'password', 'valid', 'Sample signature reason', NULL, '2d4f30df24dde0bab82ca82c17b1ea164b763cab77f70e0173747adb9b24eef5', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 5, NULL, NULL, '2026-09-06 06:46:59', '2026-09-12 06:46:59', NULL, 0),
(20, 1, 4, 5, 'review', 'I agree to the terms of this document', '2026-09-06 06:46:59', '192.168.1.187', 'password', 'revoked', 'Sample signature reason', NULL, 'c7fc035fe16b2a4a6c1457cc9814aa6ee3005682ab350d90cbc00aa52dac7383', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 1, NULL, NULL, '2026-09-11 06:46:59', '2026-09-12 06:46:59', NULL, 0);

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

--
-- Table structure for table `employee`
--

CREATE TABLE `employee` (
  `employee_id` int(11) NOT NULL,
  `department_id` int(11) NOT NULL,
  `employee_names` varchar(255) NOT NULL,
  `position` varchar(222) NOT NULL,
  `gender` varchar(444) NOT NULL,
  `address` varchar(444) DEFAULT NULL,
  `employee_email` varchar(119) DEFAULT NULL,
  `employee_phone` varchar(255) DEFAULT NULL,
  `employee_signature` varchar(444) DEFAULT NULL,
  `employee_approval_status` enum('Active','Inactive') DEFAULT NULL,
  `employee_comment` varchar(500) DEFAULT NULL,
  `is_deleted` tinyint(1) NOT NULL DEFAULT 0,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `deleted_by` int(11) DEFAULT NULL,
  `created_date` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `created_by` int(11) DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `employee`
--

INSERT INTO `employee` (`employee_id`, `department_id`, `employee_names`, `position`, `gender`, `address`, `employee_email`, `employee_phone`, `employee_signature`, `employee_approval_status`, `employee_comment`, `is_deleted`, `deleted_at`, `deleted_by`, `created_date`, `updated_at`, `created_by`, `is_active`) VALUES
(1, 5, 'Francis Wokorach', 'Finance Manager', 'Male', 'Kampala', 'info@mtlictsolutions.com', '0779930639', 'uploads/69d7423b1c90d.png', 'Active', NULL, 0, NULL, NULL, '2026-03-07 12:13:36', '2026-04-09 03:07:55', NULL, 1),
(2, 5, 'Shumi Mlingo', 'Finance Manager', 'Male', 'Kampala', 'mtlictsolutions@gmail.com', '0700467386', 'uploads/69d7424b73be3.png', 'Active', NULL, 0, NULL, NULL, '2026-03-07 12:14:14', '2026-04-09 03:08:11', NULL, 1),
(3, 5, 'Dickson Mugarura', 'Finance Manager', 'Male', 'Sentema Road', 'dd', '0700467386', 'uploads/69d7440fccea5.png', 'Active', NULL, 0, NULL, NULL, '2026-03-15 09:21:48', '2026-04-09 03:15:43', NULL, 1),
(4, 2, 'Sarah Nakato', 'HR Officer', 'Female', 'Kampala', 'sarah.nakato@example.com', '0701000001', NULL, 'Active', NULL, 0, NULL, NULL, '2026-03-15 09:36:33', '2026-03-15 09:36:33', NULL, 1),
(5, 1, 'John Okello', 'IT Support', 'Male', 'Gulu', 'john.okello@example.com', '0701000002', NULL, 'Active', NULL, 0, NULL, NULL, '2026-03-15 09:36:33', '2026-03-15 09:36:33', NULL, 1),
(6, 5, 'Grace Atim', 'Accountant', 'Female', 'Lira', 'grace.atim@example.com', '0701000003', NULL, 'Active', NULL, 0, NULL, NULL, '2026-03-15 09:36:33', '2026-03-15 09:36:33', NULL, 1),
(7, 4, 'David Kato', 'Procurement Officer', 'Male', 'Mukono', 'david.kato@example.com', '0701000004', NULL, 'Active', NULL, 0, NULL, NULL, '2026-03-15 09:36:33', '2026-03-15 09:36:33', NULL, 1),
(8, 3, 'Esther Nanyonga', 'Laboratory Technician', 'Female', 'Wakiso', 'esther.nanyonga@example.com', '0701000005', NULL, 'Active', NULL, 0, NULL, NULL, '2026-03-15 09:36:33', '2026-03-15 09:36:33', NULL, 1),
(9, 3, 'Michael Ocen', 'Quality Assurance Officer', 'Male', 'Arua', 'michael.ocen@example.com', '0701000006', NULL, 'Active', NULL, 0, NULL, NULL, '2026-03-15 09:36:33', '2026-03-15 09:36:33', NULL, 1),
(10, 2, 'Ruth Namusoke', 'Administrative Assistant', 'Female', 'Entebbe', 'ruth.namusoke@example.com', '0701000007', NULL, 'Active', NULL, 0, NULL, NULL, '2026-03-15 09:36:33', '2026-03-15 09:36:33', NULL, 1),
(11, 1, 'Patrick Ssemanda', 'Systems Administrator', 'Male', 'Kampala', 'patrick.ssemanda@example.com', '0701000008', NULL, 'Active', NULL, 0, NULL, NULL, '2026-03-15 09:41:16', '2026-03-15 09:41:16', NULL, 1),
(12, 3, 'Linda Nabwire', 'Laboratory Analyst', 'Female', 'Mbale', 'linda.nabwire@example.com', '0701000009', NULL, 'Active', NULL, 0, NULL, NULL, '2026-03-15 09:41:16', '2026-03-15 09:41:16', NULL, 1),
(13, 5, 'Samuel Turyahabwe', 'Internal Auditor', 'Male', 'Mbarara', 'samuel.turyahabwe@example.com', '0701000010', NULL, 'Active', NULL, 0, NULL, NULL, '2026-03-15 09:41:16', '2026-03-15 09:41:16', NULL, 1),
(14, 2, 'Juliet Namaganda', 'Records Officer', 'Female', 'Jinja', 'juliet.namaganda@example.com', '0701000011', NULL, 'Active', NULL, 0, NULL, NULL, '2026-03-15 09:41:16', '2026-03-15 09:41:16', NULL, 1),
(15, 3, 'Brian Ouma', 'Quality Control Officer', 'Male', 'Tororo', 'brian.ouma@example.com', '0701000012', NULL, 'Active', NULL, 0, NULL, NULL, '2026-03-15 09:41:16', '2026-03-15 09:41:16', NULL, 1),
(16, 4, 'Mukungu Danson', 'Mukyala Jolly', 'Male', 'Kampala', 'sales@mtlictsolutions.com', '0700467386', 'uploads/69b6ab86edcf0.png', 'Active', NULL, 0, NULL, NULL, '2026-03-15 09:52:22', '2026-03-15 09:52:22', NULL, 1);

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

--
-- Table structure for table `employee_competency`
--

CREATE TABLE `employee_competency` (
  `competency_id` bigint(20) UNSIGNED NOT NULL,
  `employee_id` bigint(20) UNSIGNED NOT NULL,
  `topic_id` bigint(20) UNSIGNED DEFAULT NULL,
  `curriculum_id` bigint(20) UNSIGNED DEFAULT NULL,
  `training_record_id` bigint(20) UNSIGNED DEFAULT NULL COMMENT 'Latest training that produced this competency',
  `competency_level` enum('BEGINNER','BASIC','COMPETENT','PROFICIENT','EXPERT','UNKNOWN') NOT NULL DEFAULT 'UNKNOWN',
  `status` enum('NOT_STARTED','IN_PROGRESS','PENDING_APPROVAL','COMPETENT','REQUIRES_RETRAINING','EXPIRED') NOT NULL DEFAULT 'NOT_STARTED',
  `assessment_score` decimal(5,2) DEFAULT NULL,
  `practical_score` decimal(5,2) DEFAULT NULL,
  `combined_score` decimal(5,2) DEFAULT NULL,
  `assessment_date` date DEFAULT NULL,
  `assessed_by` bigint(20) UNSIGNED DEFAULT NULL,
  `verified_by` bigint(20) UNSIGNED DEFAULT NULL,
  `verified_at` timestamp NULL DEFAULT NULL,
  `approval_status` enum('DRAFT','PENDING','APPROVED','REJECTED') NOT NULL DEFAULT 'DRAFT',
  `approved_by` bigint(20) UNSIGNED DEFAULT NULL,
  `approved_at` timestamp NULL DEFAULT NULL,
  `completed_date` date DEFAULT NULL,
  `expiry_date` date DEFAULT NULL,
  `next_assessment_date` date DEFAULT NULL,
  `certificate_number` varchar(100) DEFAULT NULL,
  `certificate_issued_date` date DEFAULT NULL,
  `comments` text DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `escalation_events`
--

CREATE TABLE `escalation_events` (
  `event_id` bigint(20) UNSIGNED NOT NULL,
  `rule_id` bigint(20) UNSIGNED NOT NULL,
  `subject_type` varchar(100) NOT NULL,
  `subject_id` bigint(20) UNSIGNED NOT NULL,
  `condition_type` varchar(50) NOT NULL,
  `days_overdue` int(11) DEFAULT NULL,
  `subject_label` varchar(255) DEFAULT NULL,
  `action_type` varchar(50) NOT NULL,
  `action_payload` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`action_payload`)),
  `action_result` varchar(50) NOT NULL DEFAULT 'SUCCESS',
  `error_message` text DEFAULT NULL,
  `notified_user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `fired_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `escalation_rules`
--

CREATE TABLE `escalation_rules` (
  `rule_id` bigint(20) UNSIGNED NOT NULL,
  `code` varchar(50) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `module` varchar(50) NOT NULL,
  `condition_type` varchar(50) NOT NULL,
  `date_field` varchar(100) NOT NULL,
  `threshold_days` int(11) NOT NULL DEFAULT 0,
  `filter_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`filter_json`)),
  `action_type` varchar(50) NOT NULL,
  `action_config` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`action_config`)),
  `status` varchar(50) NOT NULL DEFAULT 'ACTIVE',
  `version` int(10) UNSIGNED NOT NULL DEFAULT 1,
  `parent_rule_id` bigint(20) UNSIGNED DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `approved_by` bigint(20) UNSIGNED DEFAULT NULL,
  `approved_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `escalation_rules`
--

INSERT INTO `escalation_rules` (`rule_id`, `code`, `name`, `description`, `module`, `condition_type`, `date_field`, `threshold_days`, `filter_json`, `action_type`, `action_config`, `status`, `version`, `parent_rule_id`, `created_by`, `approved_by`, `approved_at`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'ESC-CAPA-001', 'CAPA Overdue — Notify Owner', 'Notify the CAPA owner when target completion date is more than 3 days past due.', 'CAPA', 'OVERDUE', 'target_completion_date', 3, NULL, 'NOTIFY_USER', '{\"title\":\"CAPA Overdue\",\"message\":\"Your assigned CAPA is overdue. Please update or request an extension.\"}', 'ACTIVE', 1, NULL, 1, 1, '2026-09-12 14:33:23', '2026-09-12 14:33:23', '2026-09-12 14:33:23', NULL),
(2, 'ESC-CAPA-002', 'CAPA 14 Days Overdue — Escalate to QA Manager', 'Escalate to the QA Manager when a CAPA is 14 days past due.', 'CAPA', 'OVERDUE', 'target_completion_date', 14, NULL, 'NOTIFY_ROLE', '{\"role\":\"qa_manager\"}', 'ACTIVE', 1, NULL, 1, 1, '2026-09-12 14:33:23', '2026-09-12 14:33:23', '2026-09-12 14:33:23', NULL),
(3, 'ESC-CAPA-003', 'CAPA Due in 7 Days', 'Early warning notification one week before CAPA due date.', 'CAPA', 'DUE_SOON', 'target_completion_date', 7, NULL, 'NOTIFY_USER', '{\"title\":\"CAPA Due Soon\",\"message\":\"Your CAPA is due in 7 days. Please begin closure activities.\"}', 'ACTIVE', 1, NULL, 1, 1, '2026-09-12 14:33:23', '2026-09-12 14:33:23', '2026-09-12 14:33:23', NULL),
(4, 'ESC-DEVI-001', 'Deviation Overdue Closure', 'Notify QA Manager when a deviation is overdue for closure.', 'DEVIATION', 'OVERDUE', 'due_date', 5, NULL, 'NOTIFY_ROLE', '{\"role\":\"qa_manager\"}', 'ACTIVE', 1, NULL, 1, 1, '2026-09-12 14:33:23', '2026-09-12 14:33:23', '2026-09-12 14:33:23', NULL),
(5, 'ESC-CHAN-001', 'Change Control — Implementation Date Passed', 'Notify the change owner when target implementation date has passed and the change is still open.', 'CHANGE_CONTROL', 'OVERDUE', 'target_implementation_date', 0, NULL, 'NOTIFY_USER', '{\"title\":\"Change Implementation Overdue\",\"message\":\"The target implementation date has passed. Please update the change status.\"}', 'ACTIVE', 1, NULL, 1, 1, '2026-09-12 14:33:23', '2026-09-12 14:33:23', '2026-09-12 14:33:23', NULL);

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

--
-- Table structure for table `failed_jobs`
--

CREATE TABLE `failed_jobs` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `uuid` varchar(255) NOT NULL,
  `connection` text NOT NULL,
  `queue` text NOT NULL,
  `payload` longtext NOT NULL,
  `exception` longtext NOT NULL,
  `failed_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `jobs`
--

CREATE TABLE `jobs` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `queue` varchar(255) NOT NULL,
  `payload` longtext NOT NULL,
  `attempts` tinyint(3) UNSIGNED NOT NULL,
  `reserved_at` int(10) UNSIGNED DEFAULT NULL,
  `available_at` int(10) UNSIGNED NOT NULL,
  `created_at` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `job_batches`
--

CREATE TABLE `job_batches` (
  `id` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `total_jobs` int(11) NOT NULL,
  `pending_jobs` int(11) NOT NULL,
  `failed_jobs` int(11) NOT NULL,
  `failed_job_ids` longtext NOT NULL,
  `options` mediumtext DEFAULT NULL,
  `cancelled_at` int(11) DEFAULT NULL,
  `created_at` int(11) NOT NULL,
  `finished_at` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `lab_sop_definitions`
--

CREATE TABLE `lab_sop_definitions` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `sop_id` bigint(20) UNSIGNED NOT NULL,
  `term` varchar(255) NOT NULL,
  `description` longtext DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `lab_sop_distribution`
--

CREATE TABLE `lab_sop_distribution` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `sop_id` bigint(20) UNSIGNED NOT NULL,
  `role` varchar(255) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `lab_sop_documents`
--

CREATE TABLE `lab_sop_documents` (
  `sop_id` bigint(20) UNSIGNED NOT NULL,
  `sop_number` varchar(50) NOT NULL,
  `document_title` varchar(255) DEFAULT NULL,
  `description` longtext DEFAULT NULL,
  `version` varchar(10) NOT NULL DEFAULT '01',
  `effective_date` date DEFAULT NULL,
  `review_date` date DEFAULT NULL,
  `objective` longtext DEFAULT NULL,
  `scope` longtext DEFAULT NULL,
  `responsibility` longtext DEFAULT NULL,
  `safety_precautions` longtext DEFAULT NULL,
  `materials_equipment` longtext DEFAULT NULL,
  `sop_references` longtext DEFAULT NULL,
  `appendices` longtext DEFAULT NULL,
  `doc_type` enum('Word_Upload_doc','Prefilled_doc') NOT NULL DEFAULT 'Prefilled_doc',
  `created_by` varchar(100) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `lab_sop_document_control`
--

CREATE TABLE `lab_sop_document_control` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `sop_id` bigint(20) UNSIGNED NOT NULL,
  `control_type` enum('Original','Controlled Copy','Uncontrolled Copy','Obsolete') NOT NULL DEFAULT 'Controlled Copy',
  `copy_number` varchar(50) DEFAULT NULL,
  `issued_to` varchar(150) DEFAULT NULL,
  `issue_date` date DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `lab_sop_edit_history`
--

CREATE TABLE `lab_sop_edit_history` (
  `history_id` bigint(20) UNSIGNED NOT NULL,
  `sop_id` bigint(20) UNSIGNED NOT NULL,
  `version_id` bigint(20) UNSIGNED DEFAULT NULL,
  `edited_by` bigint(20) UNSIGNED NOT NULL,
  `edited_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `field_name` varchar(100) NOT NULL,
  `old_value` longtext DEFAULT NULL,
  `new_value` longtext DEFAULT NULL,
  `change_description` varchar(500) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `lab_sop_procedures`
--

CREATE TABLE `lab_sop_procedures` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `sop_id` bigint(20) UNSIGNED NOT NULL,
  `section` varchar(20) DEFAULT NULL,
  `title` varchar(255) DEFAULT NULL,
  `content` longtext DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `lab_sop_records_access`
--

CREATE TABLE `lab_sop_records_access` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `sop_id` bigint(20) UNSIGNED NOT NULL,
  `staff_name` varchar(150) DEFAULT NULL,
  `staff_role` varchar(150) DEFAULT NULL,
  `access_granted` tinyint(1) NOT NULL DEFAULT 0,
  `access_date` date DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `lab_sop_versions`
--

CREATE TABLE `lab_sop_versions` (
  `version_id` bigint(20) UNSIGNED NOT NULL,
  `sop_id` bigint(20) UNSIGNED NOT NULL,
  `version_number` varchar(10) NOT NULL,
  `status` enum('Draft','Under Review','Approved','Rejected') NOT NULL DEFAULT 'Draft',
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `migrations`
--

CREATE TABLE `migrations` (
  `id` int(10) UNSIGNED NOT NULL,
  `migration` varchar(255) NOT NULL,
  `batch` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `migrations`
--

INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES
(1, '2026_08_26_020103_create_all_tables', 1),
(2, '2026_08_30_083621_create_workflow_tables', 1),
(3, '2026_08_30_141609_add_missing_columns_to_departments_table', 1),
(4, '2026_08_30_143724_add_action_at_to_universal_approval_actions_table', 1),
(5, '2026_08_30_174106_add_archived_at_to_documents_table', 1),
(6, '2026_08_30_180000_add_document_metadata_columns', 1),
(7, '2026_08_30_195656_add_electronic_signature_fields_to_documents_table', 1),
(8, '2026_09_01_000001_add_action_compatibility_columns_to_universal_approval_actions_table', 1),
(9, '2026_09_05_040211_create_lab_sop_tables', 1),
(10, '2026_09_05_080231_add_review_date_to_lab_sop_documents', 1),
(11, '2026_09_05_080528_add_reference_columns_to_notifications_table', 1),
(12, '2026_09_05_220000_create_universal_approval_attachments_table', 1),
(13, '2026_09_10_090903_create_training_categories_table', 1),
(14, '2026_09_10_091004_create_training_topics_table', 1),
(15, '2026_09_10_091751_create_training_curricula_table', 1),
(16, '2026_09_10_091850_create_curriculum_topics_table', 1),
(17, '2026_09_10_091855_create_role_curricula_table', 1),
(18, '2026_09_10_092819_create_training_requirements_table', 1),
(19, '2026_09_10_094000_create_qms_training_materials_table', 1),
(20, '2026_09_10_101244_create_qms_trainings_table', 1),
(21, '2026_09_10_101245_create_training_assessments_tables', 1),
(22, '2026_09_10_102753_create_training_acknowledgements_table', 1),
(23, '2026_09_10_102833_create_employee_competency_table', 1),
(24, '2026_09_10_102905_create_training_effectiveness_table', 1),
(25, '2026_09_10_105923_create_training_schedules_table', 1),
(26, '2026_09_10_105958_add_current_schedule_fk_to_qms_trainings', 1),
(27, '2026_09_10_110036_create_training_attendance_table', 1),
(28, '2026_09_10_110107_create_training_notifications_table', 1),
(29, '2026_09_10_110147_add_manager_to_departments', 1),
(30, '2026_09_10_111939_create_training_certificates_table', 1),
(31, '2026_09_10_172331_create_deviation_master_table', 1),
(32, '2026_09_10_172426_create_deviation_affected_items_table', 1),
(33, '2026_09_10_172454_create_deviation_containment_table', 1),
(34, '2026_09_10_172529_create_deviation_assessments_table', 1),
(35, '2026_09_10_172600_create_deviation_investigations_table', 1),
(36, '2026_09_10_172646_create_deviation_findings_table', 1),
(37, '2026_09_10_172806_create_deviation_root_causes_table', 1),
(38, '2026_09_10_172852_create_deviation_5whys_table', 1),
(39, '2026_09_10_172930_create_deviation_impacts_table', 1),
(40, '2026_09_10_173007_create_deviation_impact_items_table', 1),
(41, '2026_09_10_173040_create_deviation_actions_table', 1),
(42, '2026_09_10_173124_create_deviation_capa_linkages_table', 1),
(43, '2026_09_10_173155_create_deviation_closures_table', 1),
(44, '2026_09_10_173224_create_deviation_evidences_table', 1),
(45, '2026_09_10_173251_create_deviation_audit_trails_table', 1),
(46, '2026_09_11_000000_add_record_kind_to_deviation_masters_table', 1),
(47, '2026_09_11_035613_add_soft_deletes_to_deviation_audit_trails', 1),
(48, '2026_09_11_042800_create_capa_request_table', 1),
(49, '2026_09_11_053338_create_capa_investigations_table', 1),
(50, '2026_09_11_053434_create_capa_action_plans_table', 1),
(51, '2026_09_11_053507_create_capa_effectiveness_table', 1),
(52, '2026_09_11_053618_create_capa_documents_table', 1),
(53, '2026_09_11_053650_create_capa_closure_table', 1),
(54, '2026_09_11_053749_create_capa_extensions_table', 1),
(55, '2026_09_11_053828_create_capa_audit_trails_table', 1),
(56, '2026_09_11_065622_standardize_role_names', 1),
(57, '2026_09_11_065830_update_workflow_step_roles', 1),
(58, '2026_09_11_070337_seed_qms_workflows', 1),
(59, '2026_09_11_102906_add_approval_instance_to_capa_linkages', 1),
(60, '2026_09_11_122030_seed_capa_linkage_workflow', 1),
(61, '2026_09_11_153626_seed_capa_approval_workflows', 1),
(62, '2026_09_11_171702_create_change_control_tables', 1),
(63, '2026_09_11_171753_seed_change_control_workflows', 1),
(64, '2026_09_11_174243_split_change_approval_workflows', 1),
(65, '2026_09_11_185645_create_complaints_table', 1),
(66, '2026_09_11_185735_create_complaint_audit_trails_table', 1),
(67, '2026_09_11_185815_create_complaint_links_table', 1),
(68, '2026_09_12_090001_create_audits_table', 1),
(69, '2026_09_12_090002_create_audit_findings_table', 1),
(70, '2026_09_12_090004_create_audit_audit_trails_table', 1),
(71, '2026_09_12_090005_create_audit_links_table', 1),
(72, '2026_09_12_143713_create_suppliers_table', 2),
(73, '2026_09_12_143753_create_supplier_qualifications_table', 2),
(74, '2026_09_12_143825_create_supplier_audit_trails_table', 2),
(75, '2026_09_12_143857_create_supplier_links_table', 2),
(76, '2026_09_12_151035_create_risk_assessment_templates_table', 3),
(77, '2026_09_12_151114_create_risk_assessment_template_fields_table', 3),
(78, '2026_09_12_151248_create_risk_assessments_table', 3),
(79, '2026_09_12_151324_create_risk_assessment_items_table', 3),
(80, '2026_09_12_151357_create_risk_assessment_audit_trails_table', 3),
(81, '2026_09_12_151430_create_risk_assessment_links_table', 3),
(82, '2026_09_12_161235_create_record_links_table', 4),
(83, '2026_09_12_162421_migrate_legacy_links_to_record_links', 4),
(84, '2026_09_12_172007_create_escalation_rules_table', 5),
(85, '2026_09_12_172056_create_escalation_events_table', 5);

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

--
-- Table structure for table `modules`
--

CREATE TABLE `modules` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(255) NOT NULL,
  `display_name` varchar(255) NOT NULL,
  `icon` varchar(255) DEFAULT NULL,
  `route` varchar(255) DEFAULT NULL,
  `order` int(11) NOT NULL DEFAULT 0,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `is_system` tinyint(1) NOT NULL DEFAULT 0,
  `description` text DEFAULT NULL,
  `parent_module` varchar(255) DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `modules`
--

INSERT INTO `modules` (`id`, `name`, `display_name`, `icon`, `route`, `order`, `is_active`, `is_system`, `description`, `parent_module`, `created_by`, `updated_by`, `deleted_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'dashboard', 'Dashboard', 'fa-home', 'dashboard', 1, 1, 1, 'Main dashboard', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(2, 'documents', 'Documents', 'fa-file-alt', 'documents.index', 2, 1, 1, 'Document management', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(3, 'employees', 'Employees', 'fa-users', 'employees.index', 3, 1, 1, 'Employee management', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(4, 'approvals', 'Approvals', 'fa-check-circle', 'approvals.pending', 4, 1, 1, 'Approval management', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(5, 'users', 'Users', 'fa-users-cog', 'users.index', 5, 1, 1, 'User management', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(6, 'companies', 'Companies', 'fa-building', 'companies.index', 6, 1, 1, 'Company management', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(7, 'departments', 'Departments', 'fa-users', 'departments.index', 7, 1, 1, 'Department management', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(8, 'branches', 'Branches', 'fa-store-alt', 'branches.index', 8, 1, 1, 'Branch management', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(9, 'roles', 'Roles & Permissions', 'fa-user-lock', 'roles.index', 9, 1, 1, 'Role and permission management', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(10, 'modules', 'Modules', 'fa-puzzle-piece', 'modules.index', 10, 1, 1, 'Module management', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(11, 'audit_trails', 'Audit Trail', 'fa-history', 'audit-trails.index', 11, 1, 1, 'Audit trail logs', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(12, 'reports', 'Reports', 'fa-chart-bar', '#', 12, 1, 1, 'Reports and analytics', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(13, 'settings', 'Settings', 'fa-cog', '#', 13, 1, 1, 'System settings', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL);

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

--
-- Table structure for table `notifications`
--

CREATE TABLE `notifications` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `type` varchar(255) NOT NULL,
  `title` varchar(255) NOT NULL,
  `message` text NOT NULL,
  `data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`data`)),
  `link` varchar(255) DEFAULT NULL,
  `reference_id` bigint(20) UNSIGNED DEFAULT NULL,
  `reference_type` varchar(100) DEFAULT NULL,
  `priority` enum('low','normal','high','urgent') NOT NULL DEFAULT 'normal',
  `is_read` tinyint(1) NOT NULL DEFAULT 0,
  `read_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `notifications`
--

INSERT INTO `notifications` (`id`, `user_id`, `type`, `title`, `message`, `data`, `link`, `reference_id`, `reference_type`, `priority`, `is_read`, `read_at`, `created_by`, `updated_by`, `deleted_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 3, 'system_notification', 'Document approved', 'System maintenance scheduled for tomorrow.', NULL, NULL, NULL, NULL, 'normal', 1, '2026-09-11 15:46:59', NULL, NULL, NULL, '2026-09-07 06:46:59', '2026-09-12 06:46:59', NULL),
(2, 1, 'document_approved', 'Approval required', 'Your document has been rejected.', NULL, NULL, NULL, NULL, 'normal', 1, '2026-09-11 17:46:59', NULL, NULL, NULL, '2026-09-05 06:46:59', '2026-09-12 06:46:59', NULL),
(3, 1, 'document_rejected', 'Approval required', 'You have a new task to review.', NULL, NULL, NULL, NULL, 'normal', 1, '2026-09-12 04:46:59', NULL, NULL, NULL, '2026-09-09 06:46:59', '2026-09-12 06:46:59', NULL),
(4, 5, 'document_approved', 'Document approved', 'Your document has been rejected.', NULL, NULL, NULL, NULL, 'normal', 0, NULL, NULL, NULL, NULL, '2026-09-08 06:46:59', '2026-09-12 06:46:59', NULL),
(5, 3, 'document_approved', 'System notification', 'Your document has been approved.', NULL, NULL, NULL, NULL, 'normal', 0, NULL, NULL, NULL, NULL, '2026-09-04 06:46:59', '2026-09-12 06:46:59', NULL),
(6, 1, 'task_assigned', 'Approval required', 'Your document has been approved.', NULL, NULL, NULL, NULL, 'normal', 1, '2026-09-12 15:10:23', NULL, NULL, NULL, '2026-09-08 06:46:59', '2026-09-12 15:10:23', NULL),
(7, 5, 'approval_required', 'Approval required', 'Your document has been rejected.', NULL, NULL, NULL, NULL, 'normal', 1, '2026-09-11 17:46:59', NULL, NULL, NULL, '2026-09-09 06:46:59', '2026-09-12 06:46:59', NULL),
(8, 5, 'document_rejected', 'Document approved', 'Please review and approve the document.', NULL, NULL, NULL, NULL, 'normal', 1, '2026-09-11 07:46:59', NULL, NULL, NULL, '2026-09-03 06:46:59', '2026-09-12 06:46:59', NULL),
(9, 2, 'task_assigned', 'Approval required', 'You have a new task to review.', NULL, NULL, NULL, NULL, 'normal', 1, '2026-09-11 19:46:59', NULL, NULL, NULL, '2026-09-02 06:46:59', '2026-09-12 06:46:59', NULL),
(10, 5, 'document_rejected', 'New task assigned', 'You have a new task to review.', NULL, NULL, NULL, NULL, 'normal', 1, '2026-09-11 14:46:59', NULL, NULL, NULL, '2026-09-05 06:46:59', '2026-09-12 06:46:59', NULL),
(11, 2, 'document_approved', 'Document approved', 'You have a new task to review.', NULL, NULL, NULL, NULL, 'normal', 0, NULL, NULL, NULL, NULL, '2026-09-10 06:46:59', '2026-09-12 06:46:59', NULL),
(12, 3, 'task_assigned', 'Document approved', 'You have a new task to review.', NULL, NULL, NULL, NULL, 'normal', 0, NULL, NULL, NULL, NULL, '2026-09-04 06:46:59', '2026-09-12 06:46:59', NULL),
(13, 1, 'task_assigned', 'New task assigned', 'You have a new task to review.', NULL, NULL, NULL, NULL, 'normal', 1, '2026-09-12 15:10:23', NULL, NULL, NULL, '2026-09-09 06:46:59', '2026-09-12 15:10:23', NULL),
(14, 4, 'document_rejected', 'New task assigned', 'Your document has been rejected.', NULL, NULL, NULL, NULL, 'normal', 0, NULL, NULL, NULL, NULL, '2026-09-04 06:46:59', '2026-09-12 06:46:59', NULL),
(15, 1, 'system_notification', 'Approval required', 'You have a new task to review.', NULL, NULL, NULL, NULL, 'normal', 1, '2026-09-12 15:10:23', NULL, NULL, NULL, '2026-09-06 06:46:59', '2026-09-12 15:10:23', NULL);

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

--
-- Table structure for table `otps`
--

CREATE TABLE `otps` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `code` varchar(6) NOT NULL,
  `type` varchar(255) NOT NULL DEFAULT 'email',
  `expires_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `is_used` tinyint(1) NOT NULL DEFAULT 0,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `otps`
--

INSERT INTO `otps` (`id`, `user_id`, `code`, `type`, `expires_at`, `is_used`, `created_by`, `updated_by`, `deleted_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(2, 1, '888678', 'email', '2026-09-12 14:52:57', 1, NULL, NULL, NULL, '2026-09-12 11:52:31', '2026-09-12 11:52:57', NULL);

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

--
-- Table structure for table `password_reset_tokens`
--

CREATE TABLE `password_reset_tokens` (
  `email` varchar(255) NOT NULL,
  `token` varchar(255) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `permissions`
--

CREATE TABLE `permissions` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `module` varchar(255) NOT NULL,
  `action` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `display_name` varchar(255) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `module_id` bigint(20) UNSIGNED DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `permissions`
--

INSERT INTO `permissions` (`id`, `module`, `action`, `name`, `display_name`, `description`, `module_id`, `created_by`, `updated_by`, `deleted_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'dashboard', 'view', 'dashboard.view', 'View Dashboard', 'Ability to view Dashboard', 1, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(2, 'documents', 'view', 'documents.view', 'View Documents', 'Ability to view Documents', 2, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(3, 'documents', 'create', 'documents.create', 'Create Documents', 'Ability to create Documents', 2, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(4, 'documents', 'edit', 'documents.edit', 'Edit Documents', 'Ability to edit Documents', 2, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(5, 'documents', 'delete', 'documents.delete', 'Delete Documents', 'Ability to delete Documents', 2, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(6, 'documents', 'approve', 'documents.approve', 'Approve Documents', 'Ability to approve Documents', 2, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(7, 'documents', 'restore', 'documents.restore', 'Restore Documents', 'Ability to restore Documents', 2, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(8, 'documents', 'force_delete', 'documents.force_delete', 'Force_delete Documents', 'Ability to force_delete Documents', 2, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(9, 'documents', 'export', 'documents.export', 'Export Documents', 'Ability to export Documents', 2, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(10, 'employees', 'view', 'employees.view', 'View Employees', 'Ability to view Employees', 3, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(11, 'employees', 'create', 'employees.create', 'Create Employees', 'Ability to create Employees', 3, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(12, 'employees', 'edit', 'employees.edit', 'Edit Employees', 'Ability to edit Employees', 3, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(13, 'employees', 'delete', 'employees.delete', 'Delete Employees', 'Ability to delete Employees', 3, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(14, 'employees', 'restore', 'employees.restore', 'Restore Employees', 'Ability to restore Employees', 3, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(15, 'employees', 'force_delete', 'employees.force_delete', 'Force_delete Employees', 'Ability to force_delete Employees', 3, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(16, 'employees', 'export', 'employees.export', 'Export Employees', 'Ability to export Employees', 3, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(17, 'approvals', 'view', 'approvals.view', 'View Approvals', 'Ability to view Approvals', 4, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(18, 'approvals', 'approve', 'approvals.approve', 'Approve Approvals', 'Ability to approve Approvals', 4, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(19, 'approvals', 'reject', 'approvals.reject', 'Reject Approvals', 'Ability to reject Approvals', 4, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(20, 'approvals', 'comment', 'approvals.comment', 'Comment Approvals', 'Ability to comment Approvals', 4, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(21, 'users', 'view', 'users.view', 'View Users', 'Ability to view Users', 5, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(22, 'users', 'create', 'users.create', 'Create Users', 'Ability to create Users', 5, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(23, 'users', 'edit', 'users.edit', 'Edit Users', 'Ability to edit Users', 5, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(24, 'users', 'delete', 'users.delete', 'Delete Users', 'Ability to delete Users', 5, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(25, 'users', 'assign_roles', 'users.assign_roles', 'Assign_roles Users', 'Ability to assign_roles Users', 5, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(26, 'users', 'restore', 'users.restore', 'Restore Users', 'Ability to restore Users', 5, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(27, 'users', 'force_delete', 'users.force_delete', 'Force_delete Users', 'Ability to force_delete Users', 5, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(28, 'companies', 'view', 'companies.view', 'View Companies', 'Ability to view Companies', 6, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(29, 'companies', 'create', 'companies.create', 'Create Companies', 'Ability to create Companies', 6, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(30, 'companies', 'edit', 'companies.edit', 'Edit Companies', 'Ability to edit Companies', 6, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(31, 'companies', 'delete', 'companies.delete', 'Delete Companies', 'Ability to delete Companies', 6, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(32, 'companies', 'restore', 'companies.restore', 'Restore Companies', 'Ability to restore Companies', 6, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(33, 'companies', 'force_delete', 'companies.force_delete', 'Force_delete Companies', 'Ability to force_delete Companies', 6, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(34, 'departments', 'view', 'departments.view', 'View Departments', 'Ability to view Departments', 7, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(35, 'departments', 'create', 'departments.create', 'Create Departments', 'Ability to create Departments', 7, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(36, 'departments', 'edit', 'departments.edit', 'Edit Departments', 'Ability to edit Departments', 7, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(37, 'departments', 'delete', 'departments.delete', 'Delete Departments', 'Ability to delete Departments', 7, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(38, 'departments', 'restore', 'departments.restore', 'Restore Departments', 'Ability to restore Departments', 7, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(39, 'departments', 'export', 'departments.export', 'Export Departments', 'Ability to export Departments', 7, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(40, 'branches', 'view', 'branches.view', 'View Branches', 'Ability to view Branches', 8, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(41, 'branches', 'create', 'branches.create', 'Create Branches', 'Ability to create Branches', 8, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(42, 'branches', 'edit', 'branches.edit', 'Edit Branches', 'Ability to edit Branches', 8, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(43, 'branches', 'delete', 'branches.delete', 'Delete Branches', 'Ability to delete Branches', 8, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(44, 'branches', 'restore', 'branches.restore', 'Restore Branches', 'Ability to restore Branches', 8, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(45, 'branches', 'export', 'branches.export', 'Export Branches', 'Ability to export Branches', 8, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(46, 'roles', 'view', 'roles.view', 'View Roles', 'Ability to view Roles', 9, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(47, 'roles', 'create', 'roles.create', 'Create Roles', 'Ability to create Roles', 9, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(48, 'roles', 'edit', 'roles.edit', 'Edit Roles', 'Ability to edit Roles', 9, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(49, 'roles', 'delete', 'roles.delete', 'Delete Roles', 'Ability to delete Roles', 9, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(50, 'roles', 'assign', 'roles.assign', 'Assign Roles', 'Ability to assign Roles', 9, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(51, 'modules', 'view', 'modules.view', 'View Modules', 'Ability to view Modules', 10, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(52, 'modules', 'create', 'modules.create', 'Create Modules', 'Ability to create Modules', 10, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(53, 'modules', 'edit', 'modules.edit', 'Edit Modules', 'Ability to edit Modules', 10, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(54, 'modules', 'delete', 'modules.delete', 'Delete Modules', 'Ability to delete Modules', 10, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(55, 'modules', 'assign', 'modules.assign', 'Assign Modules', 'Ability to assign Modules', 10, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(56, 'audit_trails', 'view', 'audit_trails.view', 'View Audit trails', 'Ability to view Audit trails', 11, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(57, 'audit_trails', 'export', 'audit_trails.export', 'Export Audit trails', 'Ability to export Audit trails', 11, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(58, 'reports', 'view', 'reports.view', 'View Reports', 'Ability to view Reports', 12, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(59, 'reports', 'create', 'reports.create', 'Create Reports', 'Ability to create Reports', 12, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(60, 'reports', 'export', 'reports.export', 'Export Reports', 'Ability to export Reports', 12, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(61, 'settings', 'view', 'settings.view', 'View Settings', 'Ability to view Settings', 13, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(62, 'settings', 'edit', 'settings.edit', 'Edit Settings', 'Ability to edit Settings', 13, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(63, 'deviations', 'view', 'deviations.view', 'View deviations and nonconformances', 'View deviations and nonconformances', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(64, 'deviations', 'view_emergency', 'deviations.view_emergency', 'View emergency-flagged deviations', 'View emergency-flagged deviations', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(65, 'deviations', 'view_audit_trail', 'deviations.view_audit_trail', 'View deviation audit trail', 'View deviation audit trail', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(66, 'deviations', 'export', 'deviations.export', 'Export deviation data', 'Export deviation data', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(67, 'deviations', 'create', 'deviations.create', 'Create new deviations', 'Create new deviations', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(68, 'deviations', 'create_deviation', 'deviations.create_deviation', 'Create deviation records (record_kind=DEVIATION)', 'Create deviation records (record_kind=DEVIATION)', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(69, 'deviations', 'create_nonconformance', 'deviations.create_nonconformance', 'Create nonconformance records (record_kind=NONCONFORMANCE)', 'Create nonconformance records (record_kind=NONCONFORMANCE)', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(70, 'deviations', 'edit', 'deviations.edit', 'Edit deviations while in DRAFT / SUBMITTED', 'Edit deviations while in DRAFT / SUBMITTED', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(71, 'deviations', 'edit_locked', 'deviations.edit_locked', 'Edit deviations past DRAFT / SUBMITTED', 'Edit deviations past DRAFT / SUBMITTED', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(72, 'deviations', 'delete', 'deviations.delete', 'Soft-delete deviations (DRAFT only)', 'Soft-delete deviations (DRAFT only)', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(73, 'deviations', 'restore', 'deviations.restore', 'Restore soft-deleted deviations', 'Restore soft-deleted deviations', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(74, 'deviations', 'advance_phase', 'deviations.advance_phase', 'Advance a deviation to the next lifecycle phase', 'Advance a deviation to the next lifecycle phase', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(75, 'deviations', 'validate_gate', 'deviations.validate_gate', 'Validate phase gate prerequisites', 'Validate phase gate prerequisites', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(76, 'deviations', 'manage_affected_items', 'deviations.manage_affected_items', 'Add / edit / remove affected items and batches', 'Add / edit / remove affected items and batches', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(77, 'deviations', 'manage_containment', 'deviations.manage_containment', 'Add / edit / remove containment actions', 'Add / edit / remove containment actions', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(78, 'deviations', 'assess', 'deviations.assess', 'Complete FMEA risk assessment', 'Complete FMEA risk assessment', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(79, 'deviations', 'approve_assessment', 'deviations.approve_assessment', 'Approve risk assessment and classification', 'Approve risk assessment and classification', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(80, 'deviations', 'investigate', 'deviations.investigate', 'Create investigation plans and record findings', 'Create investigation plans and record findings', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(81, 'deviations', 'manage_findings', 'deviations.manage_findings', 'Add / edit / delete investigation findings', 'Add / edit / delete investigation findings', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(82, 'deviations', 'manage_root_causes', 'deviations.manage_root_causes', 'Add / edit / delete root cause analysis', 'Add / edit / delete root cause analysis', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(83, 'deviations', 'confirm_root_cause', 'deviations.confirm_root_cause', 'Confirm root cause as verified', 'Confirm root cause as verified', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(84, 'deviations', 'impact_assess', 'deviations.impact_assess', 'Complete impact assessment', 'Complete impact assessment', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(85, 'deviations', 'approve_impact', 'deviations.approve_impact', 'Approve impact assessment', 'Approve impact assessment', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(86, 'deviations', 'manage_impact_items', 'deviations.manage_impact_items', 'Add / edit / delete impact items', 'Add / edit / delete impact items', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(87, 'deviations', 'manage_actions', 'deviations.manage_actions', 'Create and update corrective / preventive actions', 'Create and update corrective / preventive actions', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(88, 'deviations', 'verify_actions', 'deviations.verify_actions', 'Verify completed actions', 'Verify completed actions', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(89, 'deviations', 'link_capa', 'deviations.link_capa', 'Link CAPA to deviation', 'Link CAPA to deviation', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(90, 'deviations', 'close', 'deviations.close', 'Close deviation after all prerequisites are met', 'Close deviation after all prerequisites are met', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(91, 'deviations', 'upload_evidence', 'deviations.upload_evidence', 'Upload supporting evidence files', 'Upload supporting evidence files', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(92, 'deviations', 'delete_evidence', 'deviations.delete_evidence', 'Delete uploaded evidence', 'Delete uploaded evidence', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(93, 'deviations', 'compliance.view', 'deviations.compliance.view', 'View QMS-001 compliance evidence page', 'View QMS-001 compliance evidence page', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(94, 'deviations', 'compliance.export', 'deviations.compliance.export', 'Export QMS-001 compliance evidence (CSV)', 'Export QMS-001 compliance evidence (CSV)', NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(95, 'capa', 'view', 'capa.view', 'View CAPAs', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(96, 'capa', 'create', 'capa.create', 'Create CAPAs', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(97, 'capa', 'edit', 'capa.edit', 'Edit CAPAs', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(98, 'capa', 'edit_locked', 'capa.edit_locked', 'Edit locked CAPAs', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(99, 'capa', 'delete', 'capa.delete', 'Delete CAPAs', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(100, 'capa', 'restore', 'capa.restore', 'Restore deleted CAPAs', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(101, 'capa', 'transition', 'capa.transition', 'Change CAPA status', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(102, 'capa', 'approve', 'capa.approve', 'Approve CAPAs', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(103, 'capa', 'close', 'capa.close', 'Close CAPAs', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(104, 'capa', 'reopen', 'capa.reopen', 'Reopen CAPAs', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(105, 'capa', 'investigate', 'capa.investigate', 'Conduct CAPA investigations', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(106, 'capa', 'manage_actions', 'capa.manage_actions', 'Manage CAPA action plans', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(107, 'capa', 'verify_actions', 'capa.verify_actions', 'Verify CAPA actions', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(108, 'capa', 'effectiveness', 'capa.effectiveness', 'Record effectiveness checks', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(109, 'capa', 'upload_documents', 'capa.upload_documents', 'Upload documents', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(110, 'capa', 'delete_documents', 'capa.delete_documents', 'Delete documents', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(111, 'capa', 'request_extension', 'capa.request_extension', 'Request extensions', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(112, 'capa', 'approve_extension', 'capa.approve_extension', 'Approve extensions', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(113, 'capa', 'view_audit_trail', 'capa.view_audit_trail', 'View audit trail', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(114, 'capa', 'export', 'capa.export', 'Export CAPA data', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(115, 'complaints', 'view', 'complaints.view', 'View complaints', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(116, 'complaints', 'create', 'complaints.create', 'Log complaints', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(117, 'complaints', 'edit', 'complaints.edit', 'Edit complaints', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(118, 'complaints', 'edit_locked', 'complaints.edit_locked', 'Edit locked complaints', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(119, 'complaints', 'delete', 'complaints.delete', 'Delete complaints', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(120, 'complaints', 'restore', 'complaints.restore', 'Restore deleted complaints', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(121, 'complaints', 'transition', 'complaints.transition', 'Change complaint status', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(122, 'complaints', 'approve', 'complaints.approve', 'Approve complaint closures/rejections', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(123, 'complaints', 'close', 'complaints.close', 'Close complaints', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(124, 'complaints', 'reject', 'complaints.reject', 'Reject complaints', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(125, 'complaints', 'reopen', 'complaints.reopen', 'Reopen complaints', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(126, 'complaints', 'investigate', 'complaints.investigate', 'Record investigation findings', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(127, 'complaints', 'assess_reportability', 'complaints.assess_reportability', 'Assess regulatory reportability', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(128, 'complaints', 'report', 'complaints.report', 'Submit regulatory reports', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(129, 'complaints', 'manage_links', 'complaints.manage_links', 'Manage linked records', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(130, 'complaints', 'upload_documents', 'complaints.upload_documents', 'Upload documents', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(131, 'complaints', 'delete_documents', 'complaints.delete_documents', 'Delete documents', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(132, 'complaints', 'request_extension', 'complaints.request_extension', 'Request reporting extensions', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(133, 'complaints', 'approve_extension', 'complaints.approve_extension', 'Approve reporting extensions', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(134, 'complaints', 'view_audit_trail', 'complaints.view_audit_trail', 'View audit trail', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(135, 'complaints', 'export', 'complaints.export', 'Export complaint data', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(136, 'audits', 'view', 'audits.view', 'View audits', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(137, 'audits', 'create', 'audits.create', 'Plan audits', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(138, 'audits', 'edit', 'audits.edit', 'Edit audits', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(139, 'audits', 'edit_locked', 'audits.edit_locked', 'Edit locked audits', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(140, 'audits', 'delete', 'audits.delete', 'Delete audits', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(141, 'audits', 'restore', 'audits.restore', 'Restore deleted audits', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(142, 'audits', 'transition', 'audits.transition', 'Change audit status', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(143, 'audits', 'approve', 'audits.approve', 'Approve audit closures', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(144, 'audits', 'close', 'audits.close', 'Close audits', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(145, 'audits', 'cancel', 'audits.cancel', 'Cancel audits', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(146, 'audits', 'manage_findings', 'audits.manage_findings', 'Record and edit findings', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(147, 'audits', 'respond_findings', 'audits.respond_findings', 'Respond to findings', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(148, 'audits', 'link_capa', 'audits.link_capa', 'Link findings to CAPAs', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(149, 'audits', 'manage_links', 'audits.manage_links', 'Manage linked records', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(150, 'audits', 'upload_documents', 'audits.upload_documents', 'Upload audit documents', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(151, 'audits', 'delete_documents', 'audits.delete_documents', 'Delete audit documents', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(152, 'audits', 'view_audit_trail', 'audits.view_audit_trail', 'View audit trail', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(153, 'audits', 'export', 'audits.export', 'Export audit data', NULL, NULL, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(154, 'suppliers', 'view', 'suppliers.view', 'View suppliers', NULL, NULL, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(155, 'suppliers', 'create', 'suppliers.create', 'Create supplier records', NULL, NULL, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(156, 'suppliers', 'edit', 'suppliers.edit', 'Edit suppliers', NULL, NULL, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(157, 'suppliers', 'delete', 'suppliers.delete', 'Delete suppliers', NULL, NULL, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(158, 'suppliers', 'transition', 'suppliers.transition', 'Change supplier status', NULL, NULL, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(159, 'suppliers', 'suspend', 'suppliers.suspend', 'Suspend suppliers', NULL, NULL, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(160, 'suppliers', 'disqualify', 'suppliers.disqualify', 'Disqualify suppliers', NULL, NULL, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(161, 'suppliers', 'assess_risk', 'suppliers.assess_risk', 'Assess supplier risk', NULL, NULL, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(162, 'suppliers', 'manage_qualifications', 'suppliers.manage_qualifications', 'Record qualifications', NULL, NULL, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(163, 'suppliers', 'approve_qualification', 'suppliers.approve_qualification', 'Approve qualifications', NULL, NULL, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(164, 'suppliers', 'manage_links', 'suppliers.manage_links', 'Manage linked records', NULL, NULL, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(165, 'suppliers', 'upload_documents', 'suppliers.upload_documents', 'Upload documents', NULL, NULL, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(166, 'suppliers', 'view_audit_trail', 'suppliers.view_audit_trail', 'View audit trail', NULL, NULL, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(167, 'suppliers', 'export', 'suppliers.export', 'Export supplier data', NULL, NULL, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(168, 'risk_templates', 'view', 'risk_templates.view', 'View risk templates', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(169, 'risk_templates', 'create', 'risk_templates.create', 'Create risk templates', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(170, 'risk_templates', 'edit', 'risk_templates.edit', 'Edit draft templates', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(171, 'risk_templates', 'activate', 'risk_templates.activate', 'Activate/approve templates', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(172, 'risk_templates', 'new_version', 'risk_templates.new_version', 'Create new template versions', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(173, 'risk_templates', 'delete', 'risk_templates.delete', 'Delete templates', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(174, 'risk_assessments', 'view', 'risk_assessments.view', 'View risk assessments', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(175, 'risk_assessments', 'create', 'risk_assessments.create', 'Create risk assessments', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(176, 'risk_assessments', 'edit', 'risk_assessments.edit', 'Edit assessments', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(177, 'risk_assessments', 'delete', 'risk_assessments.delete', 'Delete assessments', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(178, 'risk_assessments', 'manage_items', 'risk_assessments.manage_items', 'Add/edit FMEA items', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(179, 'risk_assessments', 'complete', 'risk_assessments.complete', 'Mark assessments completed', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(180, 'risk_assessments', 'approve', 'risk_assessments.approve', 'Approve assessments', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(181, 'risk_assessments', 'reject', 'risk_assessments.reject', 'Reject assessments', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(182, 'risk_assessments', 'manage_links', 'risk_assessments.manage_links', 'Manage linked records', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(183, 'risk_assessments', 'view_audit', 'risk_assessments.view_audit', 'View audit trail', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(184, 'risk_assessments', 'export', 'risk_assessments.export', 'Export risk data', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(185, 'kpi', 'view', 'kpi.view', 'View KPI dashboards', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(186, 'kpi', 'deviations.view', 'kpi.deviations.view', 'View deviations KPIs', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(187, 'kpi', 'capa.view', 'kpi.capa.view', 'View CAPA KPIs', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(188, 'kpi', 'change_control.view', 'kpi.change_control.view', 'View change control KPIs', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(189, 'kpi', 'complaints.view', 'kpi.complaints.view', 'View complaints KPIs', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(190, 'kpi', 'audits.view', 'kpi.audits.view', 'View audits KPIs', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(191, 'kpi', 'refresh', 'kpi.refresh', 'Force refresh KPI cache', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(192, 'kpi', 'export', 'kpi.export', 'Export KPI data', NULL, NULL, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(193, 'record_links', 'view', 'record_links.view', 'View record links', NULL, NULL, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(194, 'record_links', 'create', 'record_links.create', 'Create record links', NULL, NULL, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(195, 'record_links', 'delete', 'record_links.delete', 'Remove record links', NULL, NULL, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(196, 'record_links', 'manage', 'record_links.manage', 'Manage any record link', NULL, NULL, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(197, 'record_links', 'flush', 'record_links.flush', 'Flush link caches', NULL, NULL, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(198, 'escalations', 'view', 'escalations.view', 'View escalation rules', NULL, NULL, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(199, 'escalations', 'create', 'escalations.create', 'Create escalation rules', NULL, NULL, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(200, 'escalations', 'edit', 'escalations.edit', 'Edit escalation rules', NULL, NULL, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(201, 'escalations', 'delete', 'escalations.delete', 'Delete escalation rules', NULL, NULL, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(202, 'escalations', 'activate', 'escalations.activate', 'Activate/deactivate rules', NULL, NULL, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(203, 'escalations', 'run', 'escalations.run', 'Manually run escalation engine', NULL, NULL, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(204, 'escalations', 'view_events', 'escalations.view_events', 'View escalation event log', NULL, NULL, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL);

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

--
-- Table structure for table `qms_trainings`
--

CREATE TABLE `qms_trainings` (
  `training_id` bigint(20) UNSIGNED NOT NULL,
  `training_code` varchar(50) NOT NULL COMMENT 'Auto-generated, e.g. TRN-2026-00001',
  `topic_id` bigint(20) UNSIGNED NOT NULL,
  `curriculum_id` bigint(20) UNSIGNED DEFAULT NULL,
  `requirement_id` bigint(20) UNSIGNED DEFAULT NULL COMMENT 'Source training_requirements row',
  `document_id` bigint(20) UNSIGNED DEFAULT NULL COMMENT 'Source document when auto-assigned',
  `employee_id` bigint(20) UNSIGNED NOT NULL COMMENT 'Person being trained',
  `trainer_id` bigint(20) UNSIGNED DEFAULT NULL,
  `training_date` date DEFAULT NULL,
  `due_date` date NOT NULL,
  `started_at` timestamp NULL DEFAULT NULL,
  `completed_at` timestamp NULL DEFAULT NULL,
  `current_schedule_id` bigint(20) UNSIGNED DEFAULT NULL COMMENT 'FK added later in schedules migration',
  `reschedule_count` int(11) NOT NULL DEFAULT 0,
  `status` enum('Draft','Scheduled','In Progress','Completed','Cancelled','Deferred') NOT NULL DEFAULT 'Draft',
  `assignment_method` enum('AUTO_DOCUMENT','AUTO_ONBOARDING','AUTO_CAPA','AUTO_REQUIREMENT','MANUAL_PLAN','MANUAL_ADHOC','SELF_ENROLLED') NOT NULL DEFAULT 'MANUAL_ADHOC',
  `delivery_mode` enum('Scheduled','Self Paced','Unscheduled','Blended') NOT NULL DEFAULT 'Scheduled',
  `delivery_location` varchar(255) DEFAULT NULL,
  `delivery_platform` varchar(255) DEFAULT NULL COMMENT 'Online platform name/link',
  `effectiveness_score` decimal(5,2) DEFAULT NULL COMMENT 'Final score (from quiz or manual)',
  `effectiveness_evaluated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `effectiveness_evaluated_at` timestamp NULL DEFAULT NULL,
  `completion_override` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'TRUE if forced via LMS-008 override flow',
  `override_reason` text DEFAULT NULL COMMENT 'Required when completion_override = TRUE',
  `supervisor_comments` text DEFAULT NULL,
  `completion_notes` text DEFAULT NULL,
  `certificate_issued` tinyint(1) NOT NULL DEFAULT 0,
  `certificate_number` varchar(100) DEFAULT NULL,
  `certificate_date` date DEFAULT NULL,
  `certificate_expiry` date DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `qms_training_materials`
--

CREATE TABLE `qms_training_materials` (
  `material_id` bigint(20) UNSIGNED NOT NULL,
  `topic_id` bigint(20) UNSIGNED DEFAULT NULL COMMENT 'Topic this material supports',
  `curriculum_id` bigint(20) UNSIGNED DEFAULT NULL COMMENT 'Optional curriculum grouping',
  `document_id` bigint(20) UNSIGNED DEFAULT NULL COMMENT 'Related document/SOP',
  `material_type` enum('video','youtube','pdf','powerpoint','document','link','interactive','audio') NOT NULL,
  `material_title` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `learning_objectives` text DEFAULT NULL,
  `file_path` varchar(500) DEFAULT NULL,
  `external_url` varchar(500) DEFAULT NULL,
  `duration_minutes` int(11) DEFAULT NULL,
  `difficulty_level` enum('Beginner','Intermediate','Senior','Pro') NOT NULL DEFAULT 'Beginner',
  `display_order` int(11) NOT NULL DEFAULT 0,
  `is_mandatory` tinyint(1) NOT NULL DEFAULT 1,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `version` varchar(20) NOT NULL DEFAULT '1.0',
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `question_options`
--

CREATE TABLE `question_options` (
  `option_id` bigint(20) UNSIGNED NOT NULL,
  `question_id` bigint(20) UNSIGNED NOT NULL,
  `option_text` text NOT NULL,
  `is_correct` tinyint(1) NOT NULL DEFAULT 0,
  `display_order` int(11) NOT NULL DEFAULT 1,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `record_links`
--

CREATE TABLE `record_links` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `source_type` varchar(100) NOT NULL,
  `source_id` bigint(20) UNSIGNED NOT NULL,
  `target_type` varchar(100) NOT NULL,
  `target_id` bigint(20) UNSIGNED NOT NULL,
  `relationship` varchar(50) NOT NULL,
  `impact_notes` text DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `record_links`
--

INSERT INTO `record_links` (`id`, `source_type`, `source_id`, `target_type`, `target_id`, `relationship`, `impact_notes`, `created_by`, `created_at`, `updated_at`) VALUES
(1, 'App\\Models\\Complaint', 2, 'App\\Models\\ChangeControlMaster', 1, 'RESOLVED_BY', 'Corrective action tracked through change control CC-2026-0014 (electronic label verification).', NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00'),
(2, 'App\\Models\\Complaint', 4, 'App\\Models\\CapaRequest', 1, 'RELATED_TO', 'No CAPA required — investigation concluded no defect.', NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00'),
(3, 'App\\Models\\Audit', 2, 'App\\Models\\CapaRequest', 1, 'TRIGGERED', 'Triggered by finding F-0001 — incoming material inspection records incomplete.', NULL, '2026-09-12 07:06:51', '2026-09-12 07:06:51');

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

--
-- Table structure for table `risk_assessments`
--

CREATE TABLE `risk_assessments` (
  `assessment_id` bigint(20) UNSIGNED NOT NULL,
  `assessment_number` varchar(50) NOT NULL,
  `template_id` bigint(20) UNSIGNED NOT NULL,
  `template_version` int(10) UNSIGNED NOT NULL,
  `assessable_type` varchar(100) DEFAULT NULL,
  `assessable_id` bigint(20) UNSIGNED DEFAULT NULL,
  `title` varchar(255) NOT NULL,
  `context` text DEFAULT NULL,
  `methodology_notes` text DEFAULT NULL,
  `status` varchar(50) NOT NULL,
  `outcome` varchar(50) DEFAULT NULL,
  `max_rpn` int(10) UNSIGNED DEFAULT NULL,
  `avg_rpn` int(10) UNSIGNED DEFAULT NULL,
  `item_count` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `custom_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`custom_data`)),
  `assessor_id` bigint(20) UNSIGNED DEFAULT NULL,
  `approved_by` bigint(20) UNSIGNED DEFAULT NULL,
  `approved_at` timestamp NULL DEFAULT NULL,
  `approval_notes` text DEFAULT NULL,
  `recommended_actions` text DEFAULT NULL,
  `review_due_date` date DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `risk_assessments`
--

INSERT INTO `risk_assessments` (`assessment_id`, `assessment_number`, `template_id`, `template_version`, `assessable_type`, `assessable_id`, `title`, `context`, `methodology_notes`, `status`, `outcome`, `max_rpn`, `avg_rpn`, `item_count`, `custom_data`, `assessor_id`, `approved_by`, `approved_at`, `approval_notes`, `recommended_actions`, `review_due_date`, `created_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'RA-2026-0001', 1, 1, NULL, NULL, 'Risk Assessment — Change to Coating Material Supplier', 'Assessment of risk associated with switching to an alternate supplier of coating material (Opadry) for the Paracetamol 500mg tablet line.', NULL, 'APPROVED', 'HIGH', 180, 74, 3, '{\"affected_product\":\"Paracetamol 500mg Tablets\",\"affected_process\":\"Film coating \\u2014 Line 2\",\"regulatory_impact\":\"Low\",\"patient_impact\":false}', 1, 1, '2026-09-07 12:28:44', 'Approved with mitigation actions. Residual risk acceptable.', 'Qualify alternate supplier before releasing any lots. Add incoming inspection step. Monitor first three batches.', '2027-03-12', 1, '2026-09-12 12:28:44', '2026-09-12 12:28:44', NULL);

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

--
-- Table structure for table `risk_assessment_audit_trails`
--

CREATE TABLE `risk_assessment_audit_trails` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `assessment_id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `action_type` varchar(100) NOT NULL,
  `action_description` text DEFAULT NULL,
  `metadata` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`metadata`)),
  `changed_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `risk_assessment_audit_trails`
--

INSERT INTO `risk_assessment_audit_trails` (`id`, `assessment_id`, `user_id`, `action_type`, `action_description`, `metadata`, `changed_at`) VALUES
(1, 1, 1, 'CREATED', 'Assessment created using FMEA template.', NULL, '2026-09-02 12:28:44'),
(2, 1, 1, 'COMPLETED', 'Assessment completed. Outcome: HIGH.', NULL, '2026-09-05 12:28:44'),
(3, 1, 1, 'APPROVED', 'Approved with mitigation actions.', NULL, '2026-09-07 12:28:44');

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

--
-- Table structure for table `risk_assessment_items`
--

CREATE TABLE `risk_assessment_items` (
  `item_id` bigint(20) UNSIGNED NOT NULL,
  `assessment_id` bigint(20) UNSIGNED NOT NULL,
  `item_order` int(10) UNSIGNED NOT NULL DEFAULT 1,
  `failure_mode` varchar(500) NOT NULL,
  `potential_effect` text DEFAULT NULL,
  `potential_cause` text DEFAULT NULL,
  `severity` tinyint(3) UNSIGNED DEFAULT NULL,
  `occurrence` tinyint(3) UNSIGNED DEFAULT NULL,
  `detection` tinyint(3) UNSIGNED DEFAULT NULL,
  `rpn` int(10) UNSIGNED DEFAULT NULL,
  `risk_level` varchar(20) DEFAULT NULL,
  `current_controls` text DEFAULT NULL,
  `recommended_action` text DEFAULT NULL,
  `action_owner_id` bigint(20) UNSIGNED DEFAULT NULL,
  `action_due_date` date DEFAULT NULL,
  `action_status` varchar(50) DEFAULT NULL,
  `residual_severity` tinyint(3) UNSIGNED DEFAULT NULL,
  `residual_occurrence` tinyint(3) UNSIGNED DEFAULT NULL,
  `residual_detection` tinyint(3) UNSIGNED DEFAULT NULL,
  `residual_rpn` int(10) UNSIGNED DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `risk_assessment_items`
--

INSERT INTO `risk_assessment_items` (`item_id`, `assessment_id`, `item_order`, `failure_mode`, `potential_effect`, `potential_cause`, `severity`, `occurrence`, `detection`, `rpn`, `risk_level`, `current_controls`, `recommended_action`, `action_owner_id`, `action_due_date`, `action_status`, `residual_severity`, `residual_occurrence`, `residual_detection`, `residual_rpn`, `notes`, `created_at`, `updated_at`) VALUES
(1, 1, 1, 'Alternate supplier delivers out-of-spec coating material', 'Discolored tablets; potential batch rejection', 'Coating material not meeting required color/solubility spec', 6, 4, 3, 72, 'MEDIUM', 'Supplier CoA review; incoming visual inspection', 'Add incoming identity test for new supplier lots', NULL, NULL, 'VERIFIED', 6, 2, 2, 24, NULL, '2026-09-12 12:28:44', '2026-09-12 12:28:44'),
(2, 1, 2, 'Change in coating appearance affects patient perception', 'Customer complaint; perception of quality issue', 'Subtle color difference compared to incumbent supplier', 4, 5, 6, 120, 'HIGH', 'Retained samples comparison', 'Perform side-by-side appearance comparison on first 3 batches', NULL, NULL, 'COMPLETED', 4, 2, 2, 16, NULL, '2026-09-12 12:28:44', '2026-09-12 12:28:44'),
(3, 1, 3, 'Supplier unable to sustain supply volume', 'Production delay; backorder', 'New supplier capacity constraints', 5, 3, 2, 30, 'LOW', 'Contracted volumes', 'Maintain secondary supplier qualification', NULL, NULL, 'OPEN', 5, 2, 2, 20, NULL, '2026-09-12 12:28:44', '2026-09-12 12:28:44');

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

--
-- Table structure for table `risk_assessment_links`
--

CREATE TABLE `risk_assessment_links` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `assessment_id` bigint(20) UNSIGNED NOT NULL,
  `linked_type` varchar(100) NOT NULL,
  `linked_id` bigint(20) UNSIGNED NOT NULL,
  `relationship` varchar(50) NOT NULL,
  `impact_notes` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `risk_assessment_templates`
--

CREATE TABLE `risk_assessment_templates` (
  `template_id` bigint(20) UNSIGNED NOT NULL,
  `template_code` varchar(50) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `template_type` varchar(50) NOT NULL,
  `scope` varchar(50) NOT NULL,
  `status` varchar(50) NOT NULL,
  `version` int(10) UNSIGNED NOT NULL DEFAULT 1,
  `parent_template_id` bigint(20) UNSIGNED DEFAULT NULL,
  `scoring_config` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`scoring_config`)),
  `threshold_config` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`threshold_config`)),
  `requires_severity` tinyint(1) NOT NULL DEFAULT 1,
  `requires_occurrence` tinyint(1) NOT NULL DEFAULT 1,
  `requires_detection` tinyint(1) NOT NULL DEFAULT 1,
  `has_custom_fields` tinyint(1) NOT NULL DEFAULT 0,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `approved_by` bigint(20) UNSIGNED DEFAULT NULL,
  `approved_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `risk_assessment_templates`
--

INSERT INTO `risk_assessment_templates` (`template_id`, `template_code`, `name`, `description`, `template_type`, `scope`, `status`, `version`, `parent_template_id`, `scoring_config`, `threshold_config`, `requires_severity`, `requires_occurrence`, `requires_detection`, `has_custom_fields`, `created_by`, `approved_by`, `approved_at`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'RAT-2026-0001', 'FMEA — Change Control', 'Standard FMEA for evaluating risk of proposed changes to products, processes, or systems.', 'FMEA', 'CHANGE_CONTROL', 'ACTIVE', 1, NULL, '{\"severity\":{\"min\":1,\"max\":10},\"occurrence\":{\"min\":1,\"max\":10},\"detection\":{\"min\":1,\"max\":10}}', '[{\"min\":1,\"max\":50,\"level\":\"LOW\",\"action\":\"Acceptable \\u2014 no action required\"},{\"min\":51,\"max\":100,\"level\":\"MEDIUM\",\"action\":\"Monitor \\u2014 consider improvement\"},{\"min\":101,\"max\":200,\"level\":\"HIGH\",\"action\":\"Mitigation required\"},{\"min\":201,\"max\":1000,\"level\":\"CRITICAL\",\"action\":\"Immediate action \\/ QP approval\"}]', 1, 1, 1, 1, 1, 1, '2026-08-13 12:28:44', '2026-09-12 12:28:44', '2026-09-12 12:28:44', NULL),
(2, 'RAT-2026-0002', 'FMEA — CAPA Effectiveness', 'Risk assessment of CAPA effectiveness and residual risk.', 'FMEA', 'CAPA', 'ACTIVE', 1, NULL, NULL, NULL, 1, 1, 1, 0, 1, 1, '2026-07-29 12:28:44', '2026-09-12 12:28:44', '2026-09-12 12:28:44', NULL),
(3, 'RAT-2026-0003', 'Risk Matrix — Supplier Qualification', 'Likelihood × Impact risk matrix for supplier qualification decisions.', 'RISK_MATRIX', 'SUPPLIER', 'ACTIVE', 1, NULL, NULL, NULL, 1, 1, 0, 0, 1, 1, '2026-08-23 12:28:44', '2026-09-12 12:28:44', '2026-09-12 12:28:44', NULL);

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

--
-- Table structure for table `risk_assessment_template_fields`
--

CREATE TABLE `risk_assessment_template_fields` (
  `field_id` bigint(20) UNSIGNED NOT NULL,
  `template_id` bigint(20) UNSIGNED NOT NULL,
  `field_key` varchar(100) NOT NULL,
  `label` varchar(255) NOT NULL,
  `help_text` text DEFAULT NULL,
  `field_type` varchar(50) NOT NULL,
  `is_required` tinyint(1) NOT NULL DEFAULT 0,
  `options` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`options`)),
  `default_value` varchar(500) DEFAULT NULL,
  `min_value` int(11) DEFAULT NULL,
  `max_value` int(11) DEFAULT NULL,
  `max_length` int(11) DEFAULT NULL,
  `display_order` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `risk_assessment_template_fields`
--

INSERT INTO `risk_assessment_template_fields` (`field_id`, `template_id`, `field_key`, `label`, `help_text`, `field_type`, `is_required`, `options`, `default_value`, `min_value`, `max_value`, `max_length`, `display_order`, `created_at`, `updated_at`) VALUES
(1, 1, 'affected_product', 'Affected Product(s)', NULL, 'TEXT', 1, NULL, NULL, NULL, NULL, NULL, 1, '2026-09-12 12:28:44', '2026-09-12 12:28:44'),
(2, 1, 'affected_process', 'Affected Process', NULL, 'TEXTAREA', 0, NULL, NULL, NULL, NULL, NULL, 2, '2026-09-12 12:28:44', '2026-09-12 12:28:44'),
(3, 1, 'regulatory_impact', 'Regulatory Impact', NULL, 'SELECT', 1, '[\"None\",\"Low\",\"Medium\",\"High\"]', NULL, NULL, NULL, NULL, 3, '2026-09-12 12:28:44', '2026-09-12 12:28:44'),
(4, 1, 'patient_impact', 'Patient Impact', NULL, 'BOOLEAN', 0, NULL, NULL, NULL, NULL, NULL, 4, '2026-09-12 12:28:44', '2026-09-12 12:28:44');

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

--
-- Table structure for table `roles`
--

CREATE TABLE `roles` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(255) NOT NULL,
  `display_name` varchar(255) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `is_default` tinyint(1) NOT NULL DEFAULT 0,
  `is_system` tinyint(1) NOT NULL DEFAULT 0,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `roles`
--

INSERT INTO `roles` (`id`, `name`, `display_name`, `description`, `is_default`, `is_system`, `created_by`, `updated_by`, `deleted_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'super_admin', 'Super Administrator', 'Full system access', 0, 1, NULL, NULL, NULL, '2026-09-12 06:46:58', '2026-09-12 06:46:58', NULL),
(2, 'admin', 'Administrator', 'System administrator', 0, 1, NULL, NULL, NULL, '2026-09-12 06:46:58', '2026-09-12 06:46:58', NULL),
(3, 'manager', 'Manager', 'Department manager', 0, 1, NULL, NULL, NULL, '2026-09-12 06:46:58', '2026-09-12 06:46:58', NULL),
(4, 'approver', 'Approver', 'Quality approver', 0, 1, NULL, NULL, NULL, '2026-09-12 06:46:58', '2026-09-12 06:46:58', NULL),
(5, 'user', 'User', 'Regular user', 1, 1, NULL, NULL, NULL, '2026-09-12 06:46:58', '2026-09-12 06:46:58', NULL),
(6, 'QA Manager', 'QA Manager', NULL, 0, 0, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(7, 'QA Officer', 'QA Officer', NULL, 0, 0, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(8, 'Department Head', 'Department Head', NULL, 0, 0, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(9, 'Qualified Person', 'Qualified Person', NULL, 0, 0, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(10, 'SME', 'SME', NULL, 0, 0, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(11, 'Production Supervisor', 'Production Supervisor', NULL, 0, 0, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(12, 'QC Analyst', 'QC Analyst', NULL, 0, 0, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(13, 'Auditor', 'Auditor', NULL, 0, 0, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(14, 'qa_manager', 'QA Manager', 'QA Manager role', 0, 0, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(15, 'qa_officer', 'QA Officer', 'QA Officer role', 0, 0, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(16, 'department_head', 'Department Head', 'Department Head role', 0, 0, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(17, 'qualified_person', 'Qualified Person', 'Qualified Person role', 0, 0, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(18, 'production_supervisor', 'Production Supervisor', 'Production Supervisor role', 0, 0, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(19, 'qc_analyst', 'QC Analyst', 'QC Analyst role', 0, 0, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL);

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

--
-- Table structure for table `role_curricula`
--

CREATE TABLE `role_curricula` (
  `role_curriculum_id` bigint(20) UNSIGNED NOT NULL,
  `role_id` bigint(20) UNSIGNED NOT NULL,
  `curriculum_id` bigint(20) UNSIGNED NOT NULL,
  `is_mandatory` tinyint(1) NOT NULL DEFAULT 1,
  `auto_assign` tinyint(1) NOT NULL DEFAULT 1,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `role_permissions`
--

CREATE TABLE `role_permissions` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `role_id` bigint(20) UNSIGNED NOT NULL,
  `permission_id` bigint(20) UNSIGNED NOT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `role_permissions`
--

INSERT INTO `role_permissions` (`id`, `role_id`, `permission_id`, `created_by`, `updated_by`, `deleted_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 1, 61, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(2, 1, 59, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(3, 1, 62, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(4, 1, 54, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(5, 1, 18, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(6, 1, 44, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(7, 1, 33, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(8, 1, 60, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(9, 1, 19, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(10, 1, 20, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(11, 1, 25, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(12, 1, 55, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(13, 2, 61, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(14, 2, 59, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(15, 2, 62, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(16, 2, 54, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(17, 2, 18, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(18, 2, 44, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(19, 2, 33, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(20, 2, 60, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(21, 2, 19, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(22, 2, 20, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(23, 2, 25, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(24, 2, 55, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(25, 3, 58, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(26, 3, 59, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(27, 3, 12, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(28, 3, 13, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(29, 3, 18, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(30, 3, 14, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(31, 3, 15, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(32, 3, 60, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(33, 3, 19, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(34, 3, 20, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(35, 4, 17, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(36, 4, 3, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(37, 4, 4, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(38, 4, 5, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(39, 4, 18, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(40, 4, 7, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(41, 4, 8, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(42, 4, 9, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(43, 4, 19, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(44, 4, 20, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(45, 5, 2, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(46, 5, 3, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(47, 5, 4, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(48, 5, 5, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(49, 5, 6, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(50, 5, 7, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(51, 5, 8, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(52, 5, 9, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(53, 1, 63, NULL, NULL, NULL, NULL, NULL, NULL),
(54, 1, 64, NULL, NULL, NULL, NULL, NULL, NULL),
(55, 1, 65, NULL, NULL, NULL, NULL, NULL, NULL),
(56, 1, 66, NULL, NULL, NULL, NULL, NULL, NULL),
(57, 1, 67, NULL, NULL, NULL, NULL, NULL, NULL),
(58, 1, 68, NULL, NULL, NULL, NULL, NULL, NULL),
(59, 1, 69, NULL, NULL, NULL, NULL, NULL, NULL),
(60, 1, 70, NULL, NULL, NULL, NULL, NULL, NULL),
(61, 1, 71, NULL, NULL, NULL, NULL, NULL, NULL),
(62, 1, 72, NULL, NULL, NULL, NULL, NULL, NULL),
(63, 1, 73, NULL, NULL, NULL, NULL, NULL, NULL),
(64, 1, 74, NULL, NULL, NULL, NULL, NULL, NULL),
(65, 1, 75, NULL, NULL, NULL, NULL, NULL, NULL),
(66, 1, 76, NULL, NULL, NULL, NULL, NULL, NULL),
(67, 1, 77, NULL, NULL, NULL, NULL, NULL, NULL),
(68, 1, 78, NULL, NULL, NULL, NULL, NULL, NULL),
(69, 1, 79, NULL, NULL, NULL, NULL, NULL, NULL),
(70, 1, 80, NULL, NULL, NULL, NULL, NULL, NULL),
(71, 1, 81, NULL, NULL, NULL, NULL, NULL, NULL),
(72, 1, 82, NULL, NULL, NULL, NULL, NULL, NULL),
(73, 1, 83, NULL, NULL, NULL, NULL, NULL, NULL),
(74, 1, 84, NULL, NULL, NULL, NULL, NULL, NULL),
(75, 1, 85, NULL, NULL, NULL, NULL, NULL, NULL),
(76, 1, 86, NULL, NULL, NULL, NULL, NULL, NULL),
(77, 1, 87, NULL, NULL, NULL, NULL, NULL, NULL),
(78, 1, 88, NULL, NULL, NULL, NULL, NULL, NULL),
(79, 1, 89, NULL, NULL, NULL, NULL, NULL, NULL),
(80, 1, 90, NULL, NULL, NULL, NULL, NULL, NULL),
(81, 1, 91, NULL, NULL, NULL, NULL, NULL, NULL),
(82, 1, 92, NULL, NULL, NULL, NULL, NULL, NULL),
(83, 1, 93, NULL, NULL, NULL, NULL, NULL, NULL),
(84, 1, 94, NULL, NULL, NULL, NULL, NULL, NULL),
(85, 2, 63, NULL, NULL, NULL, NULL, NULL, NULL),
(86, 2, 64, NULL, NULL, NULL, NULL, NULL, NULL),
(87, 2, 65, NULL, NULL, NULL, NULL, NULL, NULL),
(88, 2, 66, NULL, NULL, NULL, NULL, NULL, NULL),
(89, 2, 67, NULL, NULL, NULL, NULL, NULL, NULL),
(90, 2, 68, NULL, NULL, NULL, NULL, NULL, NULL),
(91, 2, 69, NULL, NULL, NULL, NULL, NULL, NULL),
(92, 2, 70, NULL, NULL, NULL, NULL, NULL, NULL),
(93, 2, 71, NULL, NULL, NULL, NULL, NULL, NULL),
(94, 2, 72, NULL, NULL, NULL, NULL, NULL, NULL),
(95, 2, 73, NULL, NULL, NULL, NULL, NULL, NULL),
(96, 2, 74, NULL, NULL, NULL, NULL, NULL, NULL),
(97, 2, 75, NULL, NULL, NULL, NULL, NULL, NULL),
(98, 2, 76, NULL, NULL, NULL, NULL, NULL, NULL),
(99, 2, 77, NULL, NULL, NULL, NULL, NULL, NULL),
(100, 2, 78, NULL, NULL, NULL, NULL, NULL, NULL),
(101, 2, 79, NULL, NULL, NULL, NULL, NULL, NULL),
(102, 2, 80, NULL, NULL, NULL, NULL, NULL, NULL),
(103, 2, 81, NULL, NULL, NULL, NULL, NULL, NULL),
(104, 2, 82, NULL, NULL, NULL, NULL, NULL, NULL),
(105, 2, 83, NULL, NULL, NULL, NULL, NULL, NULL),
(106, 2, 84, NULL, NULL, NULL, NULL, NULL, NULL),
(107, 2, 85, NULL, NULL, NULL, NULL, NULL, NULL),
(108, 2, 86, NULL, NULL, NULL, NULL, NULL, NULL),
(109, 2, 87, NULL, NULL, NULL, NULL, NULL, NULL),
(110, 2, 88, NULL, NULL, NULL, NULL, NULL, NULL),
(111, 2, 89, NULL, NULL, NULL, NULL, NULL, NULL),
(112, 2, 90, NULL, NULL, NULL, NULL, NULL, NULL),
(113, 2, 91, NULL, NULL, NULL, NULL, NULL, NULL),
(114, 2, 92, NULL, NULL, NULL, NULL, NULL, NULL),
(115, 2, 93, NULL, NULL, NULL, NULL, NULL, NULL),
(116, 2, 94, NULL, NULL, NULL, NULL, NULL, NULL),
(117, 6, 63, NULL, NULL, NULL, NULL, NULL, NULL),
(118, 6, 64, NULL, NULL, NULL, NULL, NULL, NULL),
(119, 6, 65, NULL, NULL, NULL, NULL, NULL, NULL),
(120, 6, 66, NULL, NULL, NULL, NULL, NULL, NULL),
(121, 6, 67, NULL, NULL, NULL, NULL, NULL, NULL),
(122, 6, 68, NULL, NULL, NULL, NULL, NULL, NULL),
(123, 6, 69, NULL, NULL, NULL, NULL, NULL, NULL),
(124, 6, 70, NULL, NULL, NULL, NULL, NULL, NULL),
(125, 6, 71, NULL, NULL, NULL, NULL, NULL, NULL),
(126, 6, 72, NULL, NULL, NULL, NULL, NULL, NULL),
(127, 6, 73, NULL, NULL, NULL, NULL, NULL, NULL),
(128, 6, 74, NULL, NULL, NULL, NULL, NULL, NULL),
(129, 6, 75, NULL, NULL, NULL, NULL, NULL, NULL),
(130, 6, 76, NULL, NULL, NULL, NULL, NULL, NULL),
(131, 6, 77, NULL, NULL, NULL, NULL, NULL, NULL),
(132, 6, 78, NULL, NULL, NULL, NULL, NULL, NULL),
(133, 6, 79, NULL, NULL, NULL, NULL, NULL, NULL),
(134, 6, 80, NULL, NULL, NULL, NULL, NULL, NULL),
(135, 6, 81, NULL, NULL, NULL, NULL, NULL, NULL),
(136, 6, 82, NULL, NULL, NULL, NULL, NULL, NULL),
(137, 6, 83, NULL, NULL, NULL, NULL, NULL, NULL),
(138, 6, 84, NULL, NULL, NULL, NULL, NULL, NULL),
(139, 6, 85, NULL, NULL, NULL, NULL, NULL, NULL),
(140, 6, 86, NULL, NULL, NULL, NULL, NULL, NULL),
(141, 6, 87, NULL, NULL, NULL, NULL, NULL, NULL),
(142, 6, 88, NULL, NULL, NULL, NULL, NULL, NULL),
(143, 6, 89, NULL, NULL, NULL, NULL, NULL, NULL),
(144, 6, 90, NULL, NULL, NULL, NULL, NULL, NULL),
(145, 6, 91, NULL, NULL, NULL, NULL, NULL, NULL),
(146, 6, 92, NULL, NULL, NULL, NULL, NULL, NULL),
(147, 6, 93, NULL, NULL, NULL, NULL, NULL, NULL),
(148, 6, 94, NULL, NULL, NULL, NULL, NULL, NULL),
(149, 7, 63, NULL, NULL, NULL, NULL, NULL, NULL),
(150, 7, 65, NULL, NULL, NULL, NULL, NULL, NULL),
(151, 7, 66, NULL, NULL, NULL, NULL, NULL, NULL),
(152, 7, 67, NULL, NULL, NULL, NULL, NULL, NULL),
(153, 7, 68, NULL, NULL, NULL, NULL, NULL, NULL),
(154, 7, 69, NULL, NULL, NULL, NULL, NULL, NULL),
(155, 7, 70, NULL, NULL, NULL, NULL, NULL, NULL),
(156, 7, 76, NULL, NULL, NULL, NULL, NULL, NULL),
(157, 7, 77, NULL, NULL, NULL, NULL, NULL, NULL),
(158, 7, 78, NULL, NULL, NULL, NULL, NULL, NULL),
(159, 7, 80, NULL, NULL, NULL, NULL, NULL, NULL),
(160, 7, 81, NULL, NULL, NULL, NULL, NULL, NULL),
(161, 7, 82, NULL, NULL, NULL, NULL, NULL, NULL),
(162, 7, 84, NULL, NULL, NULL, NULL, NULL, NULL),
(163, 7, 86, NULL, NULL, NULL, NULL, NULL, NULL),
(164, 7, 87, NULL, NULL, NULL, NULL, NULL, NULL),
(165, 7, 88, NULL, NULL, NULL, NULL, NULL, NULL),
(166, 7, 89, NULL, NULL, NULL, NULL, NULL, NULL),
(167, 7, 91, NULL, NULL, NULL, NULL, NULL, NULL),
(168, 7, 93, NULL, NULL, NULL, NULL, NULL, NULL),
(169, 8, 63, NULL, NULL, NULL, NULL, NULL, NULL),
(170, 8, 64, NULL, NULL, NULL, NULL, NULL, NULL),
(171, 8, 65, NULL, NULL, NULL, NULL, NULL, NULL),
(172, 8, 66, NULL, NULL, NULL, NULL, NULL, NULL),
(173, 8, 67, NULL, NULL, NULL, NULL, NULL, NULL),
(174, 8, 68, NULL, NULL, NULL, NULL, NULL, NULL),
(175, 8, 69, NULL, NULL, NULL, NULL, NULL, NULL),
(176, 8, 70, NULL, NULL, NULL, NULL, NULL, NULL),
(177, 8, 74, NULL, NULL, NULL, NULL, NULL, NULL),
(178, 8, 75, NULL, NULL, NULL, NULL, NULL, NULL),
(179, 8, 79, NULL, NULL, NULL, NULL, NULL, NULL),
(180, 8, 84, NULL, NULL, NULL, NULL, NULL, NULL),
(181, 8, 85, NULL, NULL, NULL, NULL, NULL, NULL),
(182, 8, 87, NULL, NULL, NULL, NULL, NULL, NULL),
(183, 8, 88, NULL, NULL, NULL, NULL, NULL, NULL),
(184, 8, 93, NULL, NULL, NULL, NULL, NULL, NULL),
(185, 9, 63, NULL, NULL, NULL, NULL, NULL, NULL),
(186, 9, 64, NULL, NULL, NULL, NULL, NULL, NULL),
(187, 9, 65, NULL, NULL, NULL, NULL, NULL, NULL),
(188, 9, 66, NULL, NULL, NULL, NULL, NULL, NULL),
(189, 9, 79, NULL, NULL, NULL, NULL, NULL, NULL),
(190, 9, 85, NULL, NULL, NULL, NULL, NULL, NULL),
(191, 9, 90, NULL, NULL, NULL, NULL, NULL, NULL),
(192, 9, 93, NULL, NULL, NULL, NULL, NULL, NULL),
(193, 9, 94, NULL, NULL, NULL, NULL, NULL, NULL),
(194, 10, 63, NULL, NULL, NULL, NULL, NULL, NULL),
(195, 10, 65, NULL, NULL, NULL, NULL, NULL, NULL),
(196, 10, 80, NULL, NULL, NULL, NULL, NULL, NULL),
(197, 10, 81, NULL, NULL, NULL, NULL, NULL, NULL),
(198, 10, 82, NULL, NULL, NULL, NULL, NULL, NULL),
(199, 10, 83, NULL, NULL, NULL, NULL, NULL, NULL),
(200, 10, 93, NULL, NULL, NULL, NULL, NULL, NULL),
(201, 11, 63, NULL, NULL, NULL, NULL, NULL, NULL),
(202, 11, 67, NULL, NULL, NULL, NULL, NULL, NULL),
(203, 11, 68, NULL, NULL, NULL, NULL, NULL, NULL),
(204, 11, 69, NULL, NULL, NULL, NULL, NULL, NULL),
(205, 11, 76, NULL, NULL, NULL, NULL, NULL, NULL),
(206, 11, 77, NULL, NULL, NULL, NULL, NULL, NULL),
(207, 11, 87, NULL, NULL, NULL, NULL, NULL, NULL),
(208, 11, 91, NULL, NULL, NULL, NULL, NULL, NULL),
(209, 12, 63, NULL, NULL, NULL, NULL, NULL, NULL),
(210, 12, 67, NULL, NULL, NULL, NULL, NULL, NULL),
(211, 12, 69, NULL, NULL, NULL, NULL, NULL, NULL),
(212, 12, 76, NULL, NULL, NULL, NULL, NULL, NULL),
(213, 12, 77, NULL, NULL, NULL, NULL, NULL, NULL),
(214, 12, 91, NULL, NULL, NULL, NULL, NULL, NULL),
(215, 13, 63, NULL, NULL, NULL, NULL, NULL, NULL),
(216, 13, 65, NULL, NULL, NULL, NULL, NULL, NULL),
(217, 13, 66, NULL, NULL, NULL, NULL, NULL, NULL),
(218, 13, 93, NULL, NULL, NULL, NULL, NULL, NULL),
(219, 13, 94, NULL, NULL, NULL, NULL, NULL, NULL),
(220, 5, 63, NULL, NULL, NULL, NULL, NULL, NULL),
(221, 5, 67, NULL, NULL, NULL, NULL, NULL, NULL),
(222, 5, 68, NULL, NULL, NULL, NULL, NULL, NULL),
(223, 5, 69, NULL, NULL, NULL, NULL, NULL, NULL),
(224, 5, 91, NULL, NULL, NULL, NULL, NULL, NULL),
(225, 1, 102, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(226, 1, 112, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(227, 1, 103, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(228, 1, 96, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(229, 1, 99, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(230, 1, 110, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(231, 1, 97, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(232, 1, 98, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(233, 1, 108, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(234, 1, 114, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(235, 1, 105, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(236, 1, 106, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(237, 1, 104, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(238, 1, 111, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(239, 1, 100, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(240, 1, 101, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(241, 1, 109, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(242, 1, 107, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(243, 1, 95, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(244, 1, 113, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(245, 2, 102, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(246, 2, 112, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(247, 2, 103, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(248, 2, 96, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(249, 2, 99, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(250, 2, 110, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(251, 2, 97, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(252, 2, 98, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(253, 2, 108, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(254, 2, 114, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(255, 2, 105, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(256, 2, 106, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(257, 2, 104, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(258, 2, 111, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(259, 2, 100, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(260, 2, 101, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(261, 2, 109, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(262, 2, 107, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(263, 2, 95, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(264, 2, 113, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(265, 14, 102, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(266, 14, 112, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(267, 14, 103, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(268, 14, 96, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(269, 14, 99, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(270, 14, 110, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(271, 14, 97, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(272, 14, 98, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(273, 14, 108, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(274, 14, 114, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(275, 14, 105, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(276, 14, 106, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(277, 14, 104, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(278, 14, 111, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(279, 14, 100, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(280, 14, 101, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(281, 14, 109, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(282, 14, 107, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(283, 14, 95, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(284, 14, 113, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(285, 15, 96, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(286, 15, 97, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(287, 15, 108, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(288, 15, 105, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(289, 15, 106, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(290, 15, 101, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(291, 15, 109, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(292, 15, 107, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(293, 15, 95, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(294, 15, 113, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(295, 16, 102, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(296, 16, 96, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(297, 16, 97, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(298, 16, 108, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(299, 16, 106, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(300, 16, 101, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(301, 16, 107, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(302, 16, 95, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(303, 16, 113, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(304, 17, 102, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(305, 17, 103, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(306, 17, 95, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(307, 17, 113, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(308, 10, 105, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(309, 10, 95, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(310, 10, 113, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(311, 18, 96, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(312, 18, 106, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(313, 18, 95, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(314, 19, 96, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(315, 19, 95, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(316, 13, 114, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(317, 13, 95, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(318, 13, 113, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(319, 5, 96, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(320, 5, 95, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(321, 1, 122, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(322, 1, 133, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(323, 1, 127, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(324, 1, 123, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(325, 1, 116, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(326, 1, 119, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(327, 1, 131, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(328, 1, 117, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(329, 1, 118, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(330, 1, 135, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(331, 1, 126, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(332, 1, 129, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(333, 1, 124, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(334, 1, 125, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(335, 1, 128, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(336, 1, 132, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(337, 1, 120, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(338, 1, 121, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(339, 1, 130, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(340, 1, 115, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(341, 1, 134, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(342, 2, 122, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(343, 2, 133, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(344, 2, 127, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(345, 2, 123, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(346, 2, 116, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(347, 2, 119, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(348, 2, 131, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(349, 2, 117, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(350, 2, 118, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(351, 2, 135, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(352, 2, 126, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(353, 2, 129, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(354, 2, 124, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(355, 2, 125, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(356, 2, 128, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(357, 2, 132, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(358, 2, 120, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(359, 2, 121, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(360, 2, 130, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(361, 2, 115, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(362, 2, 134, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(363, 14, 122, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(364, 14, 133, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(365, 14, 127, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(366, 14, 123, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(367, 14, 116, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(368, 14, 119, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(369, 14, 131, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(370, 14, 117, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(371, 14, 118, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(372, 14, 135, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(373, 14, 126, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(374, 14, 129, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(375, 14, 124, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(376, 14, 125, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(377, 14, 128, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(378, 14, 132, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(379, 14, 120, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(380, 14, 121, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(381, 14, 130, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(382, 14, 115, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(383, 14, 134, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(384, 15, 127, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(385, 15, 116, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(386, 15, 117, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(387, 15, 126, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(388, 15, 129, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(389, 15, 121, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(390, 15, 130, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(391, 15, 115, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(392, 15, 134, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(393, 16, 122, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(394, 16, 127, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(395, 16, 116, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(396, 16, 117, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(397, 16, 126, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(398, 16, 129, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(399, 16, 121, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(400, 16, 115, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(401, 16, 134, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(402, 17, 122, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(403, 17, 123, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(404, 17, 128, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(405, 17, 115, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(406, 17, 134, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(407, 10, 126, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(408, 10, 115, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(409, 10, 134, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(410, 18, 116, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(411, 18, 129, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(412, 18, 115, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(413, 19, 116, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(414, 19, 115, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(415, 13, 135, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(416, 13, 115, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(417, 13, 134, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(418, 5, 116, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(419, 5, 115, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(420, 1, 143, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(421, 1, 145, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(422, 1, 144, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(423, 1, 137, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(424, 1, 140, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(425, 1, 151, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(426, 1, 138, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(427, 1, 139, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(428, 1, 153, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(429, 1, 148, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(430, 1, 146, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(431, 1, 149, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(432, 1, 147, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(433, 1, 141, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(434, 1, 142, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(435, 1, 150, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(436, 1, 136, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(437, 1, 152, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(438, 2, 143, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(439, 2, 145, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(440, 2, 144, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(441, 2, 137, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(442, 2, 140, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(443, 2, 151, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(444, 2, 138, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(445, 2, 139, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(446, 2, 153, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(447, 2, 148, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(448, 2, 146, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(449, 2, 149, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(450, 2, 147, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(451, 2, 141, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(452, 2, 142, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(453, 2, 150, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(454, 2, 136, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(455, 2, 152, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(456, 14, 143, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(457, 14, 145, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(458, 14, 144, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(459, 14, 137, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(460, 14, 140, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(461, 14, 151, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(462, 14, 138, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(463, 14, 139, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(464, 14, 153, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(465, 14, 148, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(466, 14, 146, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(467, 14, 149, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(468, 14, 147, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(469, 14, 141, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(470, 14, 142, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(471, 14, 150, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(472, 14, 136, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(473, 14, 152, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(474, 15, 137, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(475, 15, 138, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(476, 15, 148, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(477, 15, 146, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(478, 15, 149, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(479, 15, 147, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(480, 15, 142, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(481, 15, 150, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(482, 15, 136, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(483, 15, 152, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(484, 16, 143, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(485, 16, 137, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(486, 16, 138, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(487, 16, 148, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(488, 16, 147, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(489, 16, 142, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(490, 16, 136, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(491, 16, 152, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(492, 17, 143, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(493, 17, 144, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(494, 17, 136, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(495, 17, 152, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(496, 10, 147, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(497, 10, 136, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(498, 10, 152, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(499, 18, 147, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(500, 18, 136, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(501, 19, 136, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(502, 13, 137, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(503, 13, 138, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(504, 13, 153, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(505, 13, 148, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(506, 13, 146, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(507, 13, 149, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(508, 13, 142, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(509, 13, 136, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(510, 13, 152, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(511, 5, 136, NULL, NULL, NULL, '2026-09-12 06:47:00', '2026-09-12 06:47:00', NULL),
(512, 1, 163, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(513, 1, 161, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(514, 1, 155, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(515, 1, 157, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(516, 1, 160, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(517, 1, 156, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(518, 1, 167, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(519, 1, 164, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(520, 1, 162, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(521, 1, 159, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(522, 1, 158, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(523, 1, 165, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(524, 1, 154, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(525, 1, 166, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(526, 2, 163, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(527, 2, 161, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(528, 2, 155, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(529, 2, 157, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(530, 2, 160, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(531, 2, 156, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(532, 2, 167, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(533, 2, 164, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(534, 2, 162, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(535, 2, 159, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(536, 2, 158, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(537, 2, 165, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(538, 2, 154, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(539, 2, 166, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(540, 14, 163, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(541, 14, 161, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(542, 14, 155, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(543, 14, 157, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(544, 14, 160, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(545, 14, 156, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(546, 14, 167, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(547, 14, 164, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(548, 14, 162, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(549, 14, 159, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(550, 14, 158, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(551, 14, 165, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(552, 14, 154, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(553, 14, 166, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(554, 15, 161, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(555, 15, 155, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(556, 15, 156, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(557, 15, 164, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(558, 15, 162, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(559, 15, 158, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(560, 15, 165, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(561, 15, 154, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(562, 15, 166, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(563, 16, 163, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(564, 16, 161, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(565, 16, 154, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(566, 16, 166, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(567, 17, 163, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(568, 17, 160, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(569, 17, 159, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(570, 17, 154, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(571, 17, 166, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(572, 10, 161, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(573, 10, 154, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(574, 18, 154, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(575, 19, 154, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(576, 13, 167, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(577, 13, 154, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(578, 13, 166, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(579, 5, 154, NULL, NULL, NULL, '2026-09-12 11:51:39', '2026-09-12 11:51:39', NULL),
(580, 1, 180, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(581, 1, 179, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(582, 1, 175, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(583, 1, 177, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(584, 1, 176, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(585, 1, 184, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(586, 1, 178, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(587, 1, 182, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(588, 1, 181, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(589, 1, 174, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(590, 1, 183, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(591, 1, 171, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(592, 1, 169, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(593, 1, 173, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(594, 1, 170, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(595, 1, 172, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(596, 1, 168, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(597, 2, 180, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(598, 2, 179, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(599, 2, 175, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(600, 2, 177, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(601, 2, 176, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(602, 2, 184, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(603, 2, 178, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(604, 2, 182, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(605, 2, 181, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(606, 2, 174, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(607, 2, 183, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(608, 2, 171, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(609, 2, 169, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(610, 2, 173, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(611, 2, 170, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(612, 2, 172, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(613, 2, 168, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(614, 14, 180, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(615, 14, 179, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(616, 14, 175, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(617, 14, 177, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(618, 14, 176, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(619, 14, 184, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(620, 14, 178, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(621, 14, 182, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(622, 14, 181, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(623, 14, 174, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(624, 14, 183, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(625, 14, 171, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(626, 14, 169, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(627, 14, 173, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(628, 14, 170, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(629, 14, 172, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(630, 14, 168, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(631, 15, 179, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(632, 15, 175, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(633, 15, 176, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(634, 15, 178, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(635, 15, 182, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(636, 15, 174, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(637, 15, 183, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(638, 15, 168, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(639, 16, 180, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(640, 16, 174, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(641, 16, 183, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(642, 16, 168, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(643, 17, 180, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(644, 17, 181, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(645, 17, 174, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(646, 17, 183, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(647, 17, 171, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(648, 17, 168, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(649, 10, 178, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(650, 10, 174, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(651, 10, 168, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(652, 18, 174, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(653, 19, 174, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(654, 13, 184, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(655, 13, 174, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(656, 13, 183, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(657, 13, 168, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(658, 5, 174, NULL, NULL, NULL, '2026-09-12 12:28:35', '2026-09-12 12:28:35', NULL),
(659, 1, 190, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(660, 1, 187, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(661, 1, 188, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(662, 1, 189, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(663, 1, 186, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(664, 1, 192, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(665, 1, 191, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(666, 1, 185, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(667, 2, 190, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(668, 2, 187, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(669, 2, 188, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(670, 2, 189, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(671, 2, 186, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(672, 2, 192, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL);
INSERT INTO `role_permissions` (`id`, `role_id`, `permission_id`, `created_by`, `updated_by`, `deleted_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(673, 2, 191, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(674, 2, 185, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(675, 14, 190, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(676, 14, 187, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(677, 14, 188, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(678, 14, 189, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(679, 14, 186, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(680, 14, 192, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(681, 14, 191, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(682, 14, 185, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(683, 15, 190, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(684, 15, 187, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(685, 15, 188, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(686, 15, 189, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(687, 15, 186, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(688, 15, 185, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(689, 16, 190, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(690, 16, 187, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(691, 16, 188, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(692, 16, 189, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(693, 16, 186, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(694, 16, 185, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(695, 17, 190, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(696, 17, 187, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(697, 17, 189, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(698, 17, 186, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(699, 17, 185, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(700, 10, 187, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(701, 10, 186, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(702, 10, 185, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(703, 18, 185, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(704, 19, 186, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(705, 19, 185, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(706, 13, 190, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(707, 13, 188, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(708, 13, 192, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(709, 13, 185, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(710, 5, 185, NULL, NULL, NULL, '2026-09-12 12:55:34', '2026-09-12 12:55:34', NULL),
(711, 1, 194, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(712, 1, 195, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(713, 1, 197, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(714, 1, 196, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(715, 1, 193, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(716, 2, 194, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(717, 2, 195, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(718, 2, 197, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(719, 2, 196, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(720, 2, 193, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(721, 14, 194, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(722, 14, 195, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(723, 14, 197, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(724, 14, 196, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(725, 14, 193, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(726, 15, 194, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(727, 15, 195, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(728, 15, 193, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(729, 16, 194, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(730, 16, 195, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(731, 16, 193, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(732, 17, 194, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(733, 17, 193, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(734, 10, 194, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(735, 10, 193, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(736, 18, 193, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(737, 19, 193, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(738, 13, 193, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(739, 5, 193, NULL, NULL, NULL, '2026-09-12 13:25:51', '2026-09-12 13:25:51', NULL),
(740, 1, 202, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(741, 1, 199, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(742, 1, 201, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(743, 1, 200, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(744, 1, 203, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(745, 1, 198, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(746, 1, 204, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(747, 2, 202, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(748, 2, 199, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(749, 2, 201, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(750, 2, 200, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(751, 2, 203, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(752, 2, 198, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(753, 2, 204, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(754, 14, 202, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(755, 14, 199, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(756, 14, 201, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(757, 14, 200, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(758, 14, 203, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(759, 14, 198, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(760, 14, 204, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(761, 15, 198, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(762, 15, 204, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(763, 16, 198, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(764, 16, 204, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(765, 17, 202, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(766, 17, 198, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(767, 17, 204, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(768, 10, 198, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(769, 13, 198, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(770, 13, 204, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL),
(771, 5, 198, NULL, NULL, NULL, '2026-09-12 14:33:15', '2026-09-12 14:33:15', NULL);

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

--
-- Table structure for table `sessions`
--

CREATE TABLE `sessions` (
  `id` varchar(255) NOT NULL,
  `user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `ip_address` varchar(45) DEFAULT NULL,
  `user_agent` text DEFAULT NULL,
  `payload` longtext NOT NULL,
  `last_activity` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `sessions`
--

INSERT INTO `sessions` (`id`, `user_id`, `ip_address`, `user_agent`, `payload`, `last_activity`) VALUES
('zmxROjhB0HzXQkTUd2HlmrgJ6D1duF5WSQCvmRGJ', 1, '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.0.0.0 Safari/537.36', 'YTo1OntzOjY6Il90b2tlbiI7czo0MDoiWThHYk9vNXpZd1JxWmtKanlKOWkzRzFjeU8waFFwSm4zTEZLUm9GNCI7czozOiJ1cmwiO2E6MTp7czo4OiJpbnRlbmRlZCI7czozMToiaHR0cDovLzEyNy4wLjAuMTo4MDAwL2Rhc2hib2FyZCI7fXM6OToiX3ByZXZpb3VzIjthOjI6e3M6MzoidXJsIjtzOjQyOiJodHRwOi8vMTI3LjAuMC4xOjgwMDAvbm90aWZpY2F0aW9ucy9sYXRlc3QiO3M6NToicm91dGUiO3M6MjA6Im5vdGlmaWNhdGlvbnMubGF0ZXN0Ijt9czo2OiJfZmxhc2giO2E6Mjp7czozOiJvbGQiO2E6MDp7fXM6MzoibmV3IjthOjA6e319czo1MDoibG9naW5fd2ViXzU5YmEzNmFkZGMyYjJmOTQwMTU4MGYwMTRjN2Y1OGVhNGUzMDk4OWQiO2k6MTt9', 1789239738);

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

--
-- Table structure for table `suppliers`
--

CREATE TABLE `suppliers` (
  `supplier_id` bigint(20) UNSIGNED NOT NULL,
  `supplier_code` varchar(50) NOT NULL,
  `legal_name` varchar(255) NOT NULL,
  `trading_name` varchar(255) DEFAULT NULL,
  `registration_number` varchar(100) DEFAULT NULL,
  `supplier_type` varchar(50) NOT NULL,
  `risk_classification` varchar(50) NOT NULL,
  `current_status` varchar(50) NOT NULL,
  `current_phase` varchar(50) NOT NULL,
  `contact_person` varchar(255) DEFAULT NULL,
  `contact_email` varchar(255) DEFAULT NULL,
  `contact_phone` varchar(100) DEFAULT NULL,
  `address` text DEFAULT NULL,
  `country` varchar(100) DEFAULT NULL,
  `website` varchar(255) DEFAULT NULL,
  `products_services` text DEFAULT NULL,
  `manufacturer_name` varchar(255) DEFAULT NULL,
  `manufacturer_site` varchar(255) DEFAULT NULL,
  `gmp_certified` tinyint(1) NOT NULL DEFAULT 0,
  `gmp_certificate_reference` varchar(100) DEFAULT NULL,
  `gmp_certificate_expiry` date DEFAULT NULL,
  `initial_qualification_date` date DEFAULT NULL,
  `last_qualification_date` date DEFAULT NULL,
  `next_requalification_date` date DEFAULT NULL,
  `requalification_frequency_months` varchar(10) DEFAULT NULL,
  `risk_score` tinyint(3) UNSIGNED DEFAULT NULL,
  `risk_rationale` text DEFAULT NULL,
  `risk_assessed_date` date DEFAULT NULL,
  `regulatory_approved` tinyint(1) NOT NULL DEFAULT 0,
  `regulatory_notes` text DEFAULT NULL,
  `owner_id` bigint(20) UNSIGNED DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `suppliers`
--

INSERT INTO `suppliers` (`supplier_id`, `supplier_code`, `legal_name`, `trading_name`, `registration_number`, `supplier_type`, `risk_classification`, `current_status`, `current_phase`, `contact_person`, `contact_email`, `contact_phone`, `address`, `country`, `website`, `products_services`, `manufacturer_name`, `manufacturer_site`, `gmp_certified`, `gmp_certificate_reference`, `gmp_certificate_expiry`, `initial_qualification_date`, `last_qualification_date`, `next_requalification_date`, `requalification_frequency_months`, `risk_score`, `risk_rationale`, `risk_assessed_date`, `regulatory_approved`, `regulatory_notes`, `owner_id`, `created_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'SUP-2026-0001', 'Global Active Ingredients Ltd', 'GAI Pharma', 'UK-12345678', 'RAW_MATERIAL', 'CRITICAL', 'QUALIFIED', 'ACTIVE', 'Dr. Emma Whitfield', 'quality@gai-pharma.example', '+44 20 7000 0001', NULL, 'United Kingdom', NULL, 'Active pharmaceutical ingredients: paracetamol, amoxicillin, metformin.', NULL, NULL, 1, 'MHRA-GMP-2026-0042', '2027-11-12', '2024-09-12', '2025-10-12', '2026-10-12', '12', 82, 'API supplier with direct impact on finished product quality. Sole source for two key products. UK MHRA inspected with current GMP certificate.', '2026-07-14', 0, NULL, 1, 1, '2026-09-12 11:51:55', '2026-09-12 11:51:55', NULL),
(2, 'SUP-2026-0002', 'Precision Packaging Solutions Ltd', NULL, NULL, 'PACKAGING', 'MEDIUM', 'QUALIFIED', 'ACTIVE', 'Mr. Daniel Kimani', 'qa@precisionpack.example', NULL, NULL, 'Kenya', NULL, 'Primary packaging: blister film, aluminium foil, cartons.', NULL, NULL, 0, NULL, NULL, '2023-09-12', '2024-11-12', '2026-11-12', '24', 42, 'Primary packaging with moderate risk. Established supplier, no quality issues in past 24 months.', '2026-07-29', 0, NULL, 1, 1, '2026-09-12 11:51:55', '2026-09-12 11:51:55', NULL),
(3, 'SUP-2026-0003', 'BioContract Manufacturing GmbH', NULL, NULL, 'CONTRACT_MANUFACTURER', 'CRITICAL', 'QUALIFIED', 'ACTIVE', 'Frau Helga Müller', 'quality@biocontract.example', NULL, NULL, 'Germany', NULL, 'Contract manufacturing of sterile injectables.', NULL, NULL, 1, 'EU-GMP-2025-1876', '2027-05-12', '2022-09-12', '2025-10-12', '2026-10-12', '12', 88, 'Contract manufacturer of sterile products — highest risk category. Conditional qualification pending closure of two minor observations from last audit.', '2026-08-13', 0, NULL, 1, 1, '2026-09-12 11:51:55', '2026-09-12 11:58:02', NULL),
(4, 'SUP-2026-0004', 'ColdChain Logistics Ltd', NULL, NULL, 'LOGISTICS', 'HIGH', 'PENDING_QUALIFICATION', 'QUALIFICATION', 'Mr. Steven Otim', 'ops@coldchain.example', NULL, NULL, 'Uganda', NULL, 'Temperature-controlled distribution of pharmaceutical products across East Africa.', NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, '12', 62, 'Cold-chain logistics for temperature-sensitive products. New supplier — initial qualification in progress.', '2026-08-28', 0, NULL, 1, 1, '2026-09-12 11:51:55', '2026-09-12 11:51:55', NULL);

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

--
-- Table structure for table `supplier_audit_trails`
--

CREATE TABLE `supplier_audit_trails` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `supplier_id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `action_type` varchar(100) NOT NULL,
  `action_description` text DEFAULT NULL,
  `metadata` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`metadata`)),
  `changed_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `supplier_audit_trails`
--

INSERT INTO `supplier_audit_trails` (`id`, `supplier_id`, `user_id`, `action_type`, `action_description`, `metadata`, `changed_at`) VALUES
(1, 1, 1, 'CREATED', 'Supplier record created.', NULL, '2026-09-12 11:51:55'),
(2, 2, 1, 'CREATED', 'Supplier record created.', NULL, '2026-09-12 11:51:55'),
(3, 3, 1, 'CREATED', 'Supplier record created.', NULL, '2026-09-12 11:51:55'),
(4, 4, 1, 'CREATED', 'Supplier record created.', NULL, '2026-09-12 11:51:55'),
(5, 3, 1, 'STATUS_TRANSITION', 'Status changed from CONDITIONALLY_QUALIFIED to SUSPENDED. Reason: dwewewe', '{\"from\":\"CONDITIONALLY_QUALIFIED\",\"to\":\"SUSPENDED\",\"reason\":\"dwewewe\"}', '2026-09-12 11:57:52'),
(6, 3, 1, 'STATUS_TRANSITION', 'Status changed from SUSPENDED to QUALIFIED. Reason: aqsdfrgh', '{\"from\":\"SUSPENDED\",\"to\":\"QUALIFIED\",\"reason\":\"aqsdfrgh\"}', '2026-09-12 11:58:02'),
(7, 3, 1, 'LINK_ADDED', 'Linked QUALIFICATION #1', NULL, '2026-09-12 11:58:32');

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

--
-- Table structure for table `supplier_links`
--

CREATE TABLE `supplier_links` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `supplier_id` bigint(20) UNSIGNED NOT NULL,
  `linked_type` varchar(100) NOT NULL,
  `linked_id` bigint(20) UNSIGNED NOT NULL,
  `relationship` varchar(50) NOT NULL,
  `impact_notes` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `supplier_links`
--

INSERT INTO `supplier_links` (`id`, `supplier_id`, `linked_type`, `linked_id`, `relationship`, `impact_notes`, `created_at`, `updated_at`) VALUES
(1, 3, 'QUALIFICATION', 1, 'AUDITED_BY', 'zsxdfcgh', '2026-09-12 11:58:32', '2026-09-12 11:58:32');

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

--
-- Table structure for table `supplier_qualifications`
--

CREATE TABLE `supplier_qualifications` (
  `qualification_id` bigint(20) UNSIGNED NOT NULL,
  `supplier_id` bigint(20) UNSIGNED NOT NULL,
  `qualification_number` varchar(50) NOT NULL,
  `qualification_type` varchar(50) NOT NULL,
  `status` varchar(50) NOT NULL DEFAULT 'PLANNED',
  `outcome` varchar(50) DEFAULT NULL,
  `planned_date` date DEFAULT NULL,
  `actual_date` date DEFAULT NULL,
  `valid_until` date DEFAULT NULL,
  `assessor_id` bigint(20) UNSIGNED DEFAULT NULL,
  `scope` text DEFAULT NULL,
  `methodology` text DEFAULT NULL,
  `findings_summary` text DEFAULT NULL,
  `strengths` text DEFAULT NULL,
  `weaknesses` text DEFAULT NULL,
  `risk_classification` varchar(50) DEFAULT NULL,
  `risk_score` tinyint(3) UNSIGNED DEFAULT NULL,
  `risk_notes` text DEFAULT NULL,
  `conditions` text DEFAULT NULL,
  `approval_notes` text DEFAULT NULL,
  `rejection_reason` text DEFAULT NULL,
  `requires_capa` tinyint(1) NOT NULL DEFAULT 0,
  `requires_audit` tinyint(1) NOT NULL DEFAULT 0,
  `next_requalification_date` date DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `supplier_qualifications`
--

INSERT INTO `supplier_qualifications` (`qualification_id`, `supplier_id`, `qualification_number`, `qualification_type`, `status`, `outcome`, `planned_date`, `actual_date`, `valid_until`, `assessor_id`, `scope`, `methodology`, `findings_summary`, `strengths`, `weaknesses`, `risk_classification`, `risk_score`, `risk_notes`, `conditions`, `approval_notes`, `rejection_reason`, `requires_capa`, `requires_audit`, `next_requalification_date`, `created_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 1, 'Q-0001', 'INITIAL', 'APPROVED', 'QUALIFIED', '2024-09-02', '2024-09-12', '2025-09-12', 1, 'Initial qualification covering quality system, manufacturing capability, and regulatory status.', 'On-site audit, document review, and management interview.', 'Supplier demonstrated compliance with required standards. No major findings. Two minor observations closed during the audit.', NULL, NULL, 'CRITICAL', 82, NULL, NULL, NULL, NULL, 0, 0, NULL, 1, '2026-09-12 11:51:55', '2026-09-12 11:51:55', NULL),
(2, 2, 'Q-0001', 'INITIAL', 'APPROVED', 'QUALIFIED', '2023-09-02', '2023-09-12', '2024-09-12', 1, 'Initial qualification covering quality system, manufacturing capability, and regulatory status.', 'On-site audit, document review, and management interview.', 'Supplier demonstrated compliance with required standards. No major findings. Two minor observations closed during the audit.', NULL, NULL, 'MEDIUM', 42, NULL, NULL, NULL, NULL, 0, 0, NULL, 1, '2026-09-12 11:51:55', '2026-09-12 11:51:55', NULL),
(3, 3, 'Q-0001', 'INITIAL', 'APPROVED', 'QUALIFIED', '2022-09-02', '2022-09-12', '2023-09-12', 1, 'Initial qualification covering quality system, manufacturing capability, and regulatory status.', 'On-site audit, document review, and management interview.', 'Supplier demonstrated compliance with required standards. No major findings. Two minor observations closed during the audit.', NULL, NULL, 'CRITICAL', 88, NULL, NULL, NULL, NULL, 0, 0, NULL, 1, '2026-09-12 11:51:55', '2026-09-12 11:51:55', NULL);

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

--
-- Table structure for table `training_acknowledgements`
--

CREATE TABLE `training_acknowledgements` (
  `acknowledgement_id` bigint(20) UNSIGNED NOT NULL,
  `training_id` bigint(20) UNSIGNED NOT NULL,
  `employee_id` bigint(20) UNSIGNED NOT NULL,
  `material_id` bigint(20) UNSIGNED DEFAULT NULL COMMENT 'If acknowledgement is per-material',
  `acknowledged_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `signature_name` varchar(255) NOT NULL COMMENT 'Typed full name that serves as signature',
  `signature_hash` varchar(255) NOT NULL,
  `is_valid` tinyint(1) NOT NULL DEFAULT 1,
  `ip_address` varchar(45) DEFAULT NULL,
  `user_agent` text DEFAULT NULL,
  `revocation_reason` text DEFAULT NULL,
  `revoked_by` bigint(20) UNSIGNED DEFAULT NULL,
  `revoked_at` timestamp NULL DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `training_assessments`
--

CREATE TABLE `training_assessments` (
  `assessment_id` bigint(20) UNSIGNED NOT NULL,
  `topic_id` bigint(20) UNSIGNED DEFAULT NULL,
  `curriculum_id` bigint(20) UNSIGNED DEFAULT NULL,
  `assessment_title` varchar(255) NOT NULL,
  `assessment_type` enum('Pre-Test','Post-Test','Quiz','Exam','Practical') NOT NULL,
  `description` text DEFAULT NULL,
  `total_questions` int(11) NOT NULL DEFAULT 0,
  `total_points` int(11) NOT NULL DEFAULT 0,
  `passing_score` decimal(5,2) NOT NULL DEFAULT 70.00,
  `time_limit_minutes` int(11) DEFAULT NULL,
  `max_attempts` int(11) NOT NULL DEFAULT 3,
  `randomize_questions` tinyint(1) NOT NULL DEFAULT 0,
  `show_results_immediately` tinyint(1) NOT NULL DEFAULT 1,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `training_assessment_answers`
--

CREATE TABLE `training_assessment_answers` (
  `answer_id` bigint(20) UNSIGNED NOT NULL,
  `result_id` bigint(20) UNSIGNED NOT NULL,
  `question_id` bigint(20) UNSIGNED NOT NULL,
  `selected_option_id` bigint(20) UNSIGNED DEFAULT NULL,
  `answer_text` text DEFAULT NULL COMMENT 'For short_answer / essay / fill_blank',
  `is_correct` tinyint(1) NOT NULL DEFAULT 0,
  `points_earned` int(11) NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `training_assessment_results`
--

CREATE TABLE `training_assessment_results` (
  `result_id` bigint(20) UNSIGNED NOT NULL,
  `training_id` bigint(20) UNSIGNED DEFAULT NULL,
  `assessment_id` bigint(20) UNSIGNED DEFAULT NULL,
  `employee_id` bigint(20) UNSIGNED DEFAULT NULL,
  `attempt_number` int(11) NOT NULL DEFAULT 1,
  `total_questions` int(11) NOT NULL DEFAULT 0,
  `correct_answers` int(11) NOT NULL DEFAULT 0,
  `incorrect_answers` int(11) NOT NULL DEFAULT 0,
  `unanswered` int(11) NOT NULL DEFAULT 0,
  `total_points` int(11) NOT NULL DEFAULT 0,
  `points_earned` int(11) NOT NULL DEFAULT 0,
  `score` decimal(5,2) NOT NULL DEFAULT 0.00,
  `passing_score` decimal(5,2) NOT NULL DEFAULT 70.00,
  `is_passed` tinyint(1) NOT NULL DEFAULT 0,
  `time_taken` int(11) NOT NULL DEFAULT 0 COMMENT 'Seconds',
  `started_at` timestamp NULL DEFAULT NULL,
  `completed_at` timestamp NULL DEFAULT NULL,
  `reviewed_by` bigint(20) UNSIGNED DEFAULT NULL,
  `reviewed_at` timestamp NULL DEFAULT NULL,
  `reviewer_comments` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `training_attendance`
--

CREATE TABLE `training_attendance` (
  `attendance_id` bigint(20) UNSIGNED NOT NULL,
  `training_id` bigint(20) UNSIGNED NOT NULL,
  `schedule_id` bigint(20) UNSIGNED DEFAULT NULL,
  `employee_id` bigint(20) UNSIGNED NOT NULL,
  `attendance_date` date NOT NULL,
  `check_in_time` time DEFAULT NULL,
  `check_out_time` time DEFAULT NULL,
  `status` enum('Present','Absent','Late','Excused','Partial') NOT NULL DEFAULT 'Present',
  `signature_name` varchar(255) DEFAULT NULL,
  `signature_hash` varchar(255) DEFAULT NULL,
  `signature_timestamp` timestamp NULL DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `recorded_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `training_categories`
--

CREATE TABLE `training_categories` (
  `category_id` bigint(20) UNSIGNED NOT NULL,
  `category_code` varchar(50) NOT NULL,
  `category_name` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `requires_certification` tinyint(1) NOT NULL DEFAULT 0,
  `validity_months` int(11) DEFAULT NULL COMMENT 'Certification validity period in months',
  `is_mandatory` tinyint(1) NOT NULL DEFAULT 0,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `training_certificates`
--

CREATE TABLE `training_certificates` (
  `certificate_id` bigint(20) UNSIGNED NOT NULL,
  `certificate_number` varchar(100) NOT NULL,
  `verification_code` varchar(50) NOT NULL COMMENT 'Public verification code',
  `training_id` bigint(20) UNSIGNED DEFAULT NULL,
  `competency_id` bigint(20) UNSIGNED DEFAULT NULL,
  `employee_id` bigint(20) UNSIGNED NOT NULL,
  `topic_id` bigint(20) UNSIGNED DEFAULT NULL,
  `curriculum_id` bigint(20) UNSIGNED DEFAULT NULL,
  `issue_date` date NOT NULL,
  `expiry_date` date DEFAULT NULL,
  `template_used` varchar(100) DEFAULT NULL,
  `file_path` varchar(500) DEFAULT NULL COMMENT 'Path to generated PDF',
  `issued_by` bigint(20) UNSIGNED DEFAULT NULL,
  `status` enum('Active','Expired','Revoked','Replaced') NOT NULL DEFAULT 'Active',
  `revocation_reason` text DEFAULT NULL,
  `revoked_by` bigint(20) UNSIGNED DEFAULT NULL,
  `revoked_at` timestamp NULL DEFAULT NULL,
  `replaces_certificate_id` bigint(20) UNSIGNED DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `training_curricula`
--

CREATE TABLE `training_curricula` (
  `curriculum_id` bigint(20) UNSIGNED NOT NULL,
  `curriculum_code` varchar(50) NOT NULL,
  `curriculum_name` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `version` varchar(20) NOT NULL DEFAULT '1.0',
  `effective_date` date DEFAULT NULL,
  `expiry_date` date DEFAULT NULL,
  `is_onboarding` tinyint(1) NOT NULL DEFAULT 0,
  `recurrence_months` int(11) DEFAULT NULL COMMENT 'Retraining cycle in months, null = one-time',
  `default_delivery_mode` enum('Scheduled','Self Paced','Unscheduled','Blended') NOT NULL DEFAULT 'Scheduled',
  `total_duration_hours` decimal(8,2) DEFAULT NULL,
  `target_role_ids` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`target_role_ids`)),
  `target_department_ids` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`target_department_ids`)),
  `workflow_id` bigint(20) UNSIGNED DEFAULT NULL,
  `workflow_instance_id` bigint(20) UNSIGNED DEFAULT NULL,
  `approval_status` enum('DRAFT','PENDING','APPROVED','REJECTED') NOT NULL DEFAULT 'DRAFT',
  `approved_by` bigint(20) UNSIGNED DEFAULT NULL,
  `approved_at` timestamp NULL DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `training_effectiveness`
--

CREATE TABLE `training_effectiveness` (
  `effectiveness_id` bigint(20) UNSIGNED NOT NULL,
  `training_id` bigint(20) UNSIGNED NOT NULL,
  `employee_id` bigint(20) UNSIGNED NOT NULL,
  `evaluation_type` enum('Immediate','30-Day','60-Day','90-Day','Annual') NOT NULL,
  `evaluation_date` date NOT NULL,
  `knowledge_score` decimal(5,2) DEFAULT NULL COMMENT 'Level 2: Learning',
  `skill_score` decimal(5,2) DEFAULT NULL COMMENT 'Level 3: Behavior — Skill',
  `behavior_score` decimal(5,2) DEFAULT NULL COMMENT 'Level 3: Behavior',
  `results_score` decimal(5,2) DEFAULT NULL COMMENT 'Level 4: Results',
  `overall_effectiveness` decimal(5,2) DEFAULT NULL,
  `effectiveness_status` enum('Effective','Partially Effective','Not Effective','Pending Evaluation') NOT NULL DEFAULT 'Pending Evaluation',
  `evaluation_method` enum('Observation','Interview','Survey','Test','KPI Analysis','Combination') NOT NULL DEFAULT 'Combination',
  `strengths` text DEFAULT NULL,
  `areas_for_improvement` text DEFAULT NULL,
  `recommendations` text DEFAULT NULL,
  `follow_up_required` tinyint(1) NOT NULL DEFAULT 0,
  `follow_up_date` date DEFAULT NULL,
  `follow_up_notes` text DEFAULT NULL,
  `monitored_by` bigint(20) UNSIGNED DEFAULT NULL,
  `monitoring_date` date DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `training_escalation_log`
--

CREATE TABLE `training_escalation_log` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `training_id` bigint(20) UNSIGNED NOT NULL,
  `employee_id` bigint(20) UNSIGNED NOT NULL,
  `escalated_to` bigint(20) UNSIGNED DEFAULT NULL,
  `escalation_level` int(11) NOT NULL DEFAULT 1,
  `reason` text NOT NULL,
  `email_sent` tinyint(1) NOT NULL DEFAULT 0,
  `escalated_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `training_notifications`
--

CREATE TABLE `training_notifications` (
  `notification_id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `training_id` bigint(20) UNSIGNED DEFAULT NULL,
  `notification_type` enum('Training_Assigned','Training_Reminder','Training_Overdue','Assessment_Due','Certification_Expiring','Training_Completed','Effectiveness_Evaluation_Due','Escalation_Manager') NOT NULL,
  `title` varchar(255) NOT NULL,
  `message` text NOT NULL,
  `priority` enum('low','normal','high','urgent') NOT NULL DEFAULT 'normal',
  `is_read` tinyint(1) NOT NULL DEFAULT 0,
  `read_at` timestamp NULL DEFAULT NULL,
  `email_sent` tinyint(1) NOT NULL DEFAULT 0,
  `email_sent_at` timestamp NULL DEFAULT NULL,
  `is_escalation` tinyint(1) NOT NULL DEFAULT 0,
  `escalated_to_user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `escalation_level` int(11) NOT NULL DEFAULT 0,
  `scheduled_for` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `training_requirements`
--

CREATE TABLE `training_requirements` (
  `requirement_id` bigint(20) UNSIGNED NOT NULL,
  `requirement_code` varchar(50) NOT NULL,
  `trigger_type` enum('DOCUMENT_REVISION','NEW_EMPLOYEE','ROLE_CHANGE','CAPA','RETRAINING_CYCLE','ANNUAL_PLAN','MANUAL_ASSIGNMENT') NOT NULL,
  `trigger_id` bigint(20) UNSIGNED DEFAULT NULL COMMENT 'ID of the triggering record (document, CAPA, etc.)',
  `trigger_reference` varchar(255) DEFAULT NULL COMMENT 'Human-readable reference, e.g. DOC/2026/0001',
  `topic_id` bigint(20) UNSIGNED DEFAULT NULL,
  `curriculum_id` bigint(20) UNSIGNED DEFAULT NULL,
  `target_role_ids` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`target_role_ids`)),
  `target_employee_ids` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`target_employee_ids`)),
  `target_department_ids` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`target_department_ids`)),
  `due_date` date NOT NULL,
  `priority` enum('LOW','MEDIUM','HIGH','CRITICAL') NOT NULL DEFAULT 'MEDIUM',
  `status` enum('PENDING','ASSIGNED','IN_PROGRESS','COMPLETED','OVERDUE','CANCELLED') NOT NULL DEFAULT 'PENDING',
  `workflow_id` bigint(20) UNSIGNED DEFAULT NULL,
  `workflow_instance_id` bigint(20) UNSIGNED DEFAULT NULL,
  `approval_status` enum('DRAFT','PENDING','APPROVED','REJECTED') NOT NULL DEFAULT 'DRAFT',
  `approved_by` bigint(20) UNSIGNED DEFAULT NULL,
  `approved_at` timestamp NULL DEFAULT NULL,
  `linked_capa_id` bigint(20) UNSIGNED DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `training_reschedule_log`
--

CREATE TABLE `training_reschedule_log` (
  `log_id` bigint(20) UNSIGNED NOT NULL,
  `training_id` bigint(20) UNSIGNED NOT NULL,
  `schedule_id` bigint(20) UNSIGNED DEFAULT NULL,
  `old_date` date NOT NULL,
  `new_date` date NOT NULL,
  `old_start_time` time DEFAULT NULL,
  `new_start_time` time DEFAULT NULL,
  `reason` text NOT NULL,
  `rescheduled_by` bigint(20) UNSIGNED DEFAULT NULL,
  `rescheduled_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `training_schedules`
--

CREATE TABLE `training_schedules` (
  `schedule_id` bigint(20) UNSIGNED NOT NULL,
  `training_id` bigint(20) UNSIGNED NOT NULL,
  `scheduled_date` date NOT NULL,
  `start_time` time DEFAULT NULL,
  `end_time` time DEFAULT NULL,
  `duration_hours` decimal(5,2) DEFAULT NULL,
  `location` varchar(255) DEFAULT NULL,
  `venue_type` enum('On-Site','Off-Site','Online','Hybrid') NOT NULL DEFAULT 'On-Site',
  `online_link` varchar(255) DEFAULT NULL,
  `trainer_id` bigint(20) UNSIGNED DEFAULT NULL,
  `co_trainer_id` bigint(20) UNSIGNED DEFAULT NULL,
  `max_participants` int(11) DEFAULT NULL,
  `status` enum('SCHEDULED','CONFIRMED','IN_PROGRESS','COMPLETED','CANCELLED','RESCHEDULED') NOT NULL DEFAULT 'SCHEDULED',
  `notes` text DEFAULT NULL,
  `reminder_sent` tinyint(1) NOT NULL DEFAULT 0,
  `reminder_sent_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `training_topics`
--

CREATE TABLE `training_topics` (
  `topic_id` bigint(20) UNSIGNED NOT NULL,
  `category_id` bigint(20) UNSIGNED DEFAULT NULL,
  `topic_code` varchar(50) NOT NULL,
  `topic_name` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `learning_objectives` text DEFAULT NULL,
  `target_audience` text DEFAULT NULL,
  `prerequisites` text DEFAULT NULL,
  `default_duration_hours` decimal(5,2) DEFAULT NULL,
  `recurrence_months` int(11) DEFAULT NULL COMMENT 'How often retraining is required',
  `completion_method` enum('ACKNOWLEDGEMENT','QUIZ','PRACTICAL','BOTH') NOT NULL DEFAULT 'ACKNOWLEDGEMENT',
  `assessment_required` tinyint(1) NOT NULL DEFAULT 0,
  `passing_score` decimal(5,2) NOT NULL DEFAULT 70.00,
  `max_attempts` int(11) NOT NULL DEFAULT 3,
  `requires_practical_assessment` tinyint(1) NOT NULL DEFAULT 0,
  `document_id` bigint(20) UNSIGNED DEFAULT NULL COMMENT 'Related SOP/document for auto-assignment trigger',
  `sop_reference` varchar(255) DEFAULT NULL,
  `regulatory_reference` text DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `universal_approval_actions`
--

CREATE TABLE `universal_approval_actions` (
  `action_id` bigint(20) UNSIGNED NOT NULL,
  `instance_id` bigint(20) UNSIGNED NOT NULL,
  `step_id` bigint(20) UNSIGNED NOT NULL,
  `approver_user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `action` varchar(50) NOT NULL,
  `comment` text DEFAULT NULL,
  `action_type` varchar(255) NOT NULL DEFAULT 'PENDING',
  `signature` varchar(255) DEFAULT NULL,
  `comments` text DEFAULT NULL,
  `action_at` timestamp NULL DEFAULT NULL,
  `signature_path` varchar(255) DEFAULT NULL,
  `signature_hash` text DEFAULT NULL,
  `signature_ip` varchar(45) DEFAULT NULL,
  `signature_user_agent` text DEFAULT NULL,
  `ip_address` varchar(45) DEFAULT NULL,
  `user_agent` text DEFAULT NULL,
  `action_date` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `universal_approval_actions`
--

INSERT INTO `universal_approval_actions` (`action_id`, `instance_id`, `step_id`, `approver_user_id`, `action`, `comment`, `action_type`, `signature`, `comments`, `action_at`, `signature_path`, `signature_hash`, `signature_ip`, `signature_user_agent`, `ip_address`, `user_agent`, `action_date`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
(1, 2, 1, 3, 'APPROVE', 'Satisfied with the corrective actions proposed.', 'APPROVE', NULL, 'Concur with the investigation findings.', '2026-09-01 09:47:00', NULL, '4b1812fdb0edc9e5da5e4837fac88dba63dd48e783c0283ab220a54cc6abb414', '192.168.1.54', 'Mozilla/5.0 (Seeder)', '192.168.1.145', 'Mozilla/5.0 (Seeder)', '2026-09-01 09:47:00', NULL, NULL, '2026-09-01 09:47:00', '2026-09-01 09:47:00'),
(2, 2, 2, 4, 'APPROVE', 'Approved — all prerequisites met.', 'APPROVE', NULL, 'Concur with the investigation findings.', '2026-09-03 11:47:00', NULL, '7c840032f060bd266c50c1a64956a0f2e8d2f1439cd94ccd781ce1793eb3a3cc', '192.168.1.197', 'Mozilla/5.0 (Seeder)', '192.168.1.115', 'Mozilla/5.0 (Seeder)', '2026-09-03 11:47:00', NULL, NULL, '2026-09-03 11:47:00', '2026-09-03 11:47:00');

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

--
-- Table structure for table `universal_approval_attachments`
--

CREATE TABLE `universal_approval_attachments` (
  `attachment_id` bigint(20) UNSIGNED NOT NULL,
  `action_id` bigint(20) UNSIGNED NOT NULL,
  `file_name` varchar(255) NOT NULL,
  `file_path` varchar(255) NOT NULL,
  `file_size` int(11) NOT NULL,
  `file_type` varchar(255) NOT NULL,
  `uploaded_by` bigint(20) UNSIGNED NOT NULL,
  `uploaded_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `universal_approval_delegations`
--

CREATE TABLE `universal_approval_delegations` (
  `delegation_id` bigint(20) UNSIGNED NOT NULL,
  `original_user_id` bigint(20) UNSIGNED NOT NULL,
  `delegated_user_id` bigint(20) UNSIGNED NOT NULL,
  `workflow_id` bigint(20) UNSIGNED DEFAULT NULL,
  `module_type` varchar(255) DEFAULT NULL,
  `start_date` datetime NOT NULL,
  `end_date` datetime NOT NULL,
  `reason` text DEFAULT NULL,
  `status` varchar(255) NOT NULL DEFAULT 'ACTIVE',
  `created_by` bigint(20) UNSIGNED NOT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `cancelled_by` bigint(20) UNSIGNED DEFAULT NULL,
  `cancelled_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `universal_approval_delegations`
--

INSERT INTO `universal_approval_delegations` (`delegation_id`, `original_user_id`, `delegated_user_id`, `workflow_id`, `module_type`, `start_date`, `end_date`, `reason`, `status`, `created_by`, `updated_by`, `deleted_by`, `cancelled_by`, `cancelled_at`, `deleted_at`, `created_at`, `updated_at`) VALUES
(1, 1, 3, NULL, NULL, '2026-09-07 09:47:00', '2026-09-17 09:47:00', 'Annual leave — QA Manager delegated to QA Officer.', 'ACTIVE', 1, 1, NULL, NULL, NULL, NULL, '2026-09-07 06:47:00', '2026-09-07 06:47:00'),
(2, 4, 5, NULL, NULL, '2026-09-10 09:47:00', '2026-09-17 09:47:00', 'Business travel — delegation during site visit.', 'ACTIVE', 4, 4, NULL, NULL, NULL, NULL, '2026-09-10 06:47:00', '2026-09-10 06:47:00'),
(3, 4, 5, NULL, NULL, '2026-08-13 09:47:00', '2026-08-18 09:47:00', 'Sick leave — short-term delegation.', 'EXPIRED', 4, 4, NULL, NULL, NULL, NULL, '2026-08-13 06:47:00', '2026-08-13 06:47:00'),
(4, 5, 1, NULL, NULL, '2026-08-23 09:47:00', '2026-08-27 09:47:00', 'Conference attendance — temporary coverage.', 'CANCELLED', 5, 5, NULL, 5, '2026-08-25 06:47:00', NULL, '2026-08-23 06:47:00', '2026-08-25 06:47:00'),
(5, 4, 2, NULL, NULL, '2026-09-11 09:47:00', '2026-09-14 09:47:00', 'Public holiday coverage.', 'ACTIVE', 4, 4, NULL, NULL, NULL, NULL, '2026-09-11 06:47:00', '2026-09-11 06:47:00');

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

--
-- Table structure for table `universal_approval_instances`
--

CREATE TABLE `universal_approval_instances` (
  `instance_id` bigint(20) UNSIGNED NOT NULL,
  `workflow_id` bigint(20) UNSIGNED NOT NULL,
  `record_id` bigint(20) UNSIGNED DEFAULT NULL,
  `record_type` varchar(100) NOT NULL,
  `record_number` varchar(100) DEFAULT NULL,
  `record_title` varchar(255) DEFAULT NULL,
  `initiated_by` bigint(20) UNSIGNED NOT NULL,
  `initiated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `current_step` int(11) NOT NULL DEFAULT 1,
  `status` enum('PENDING','IN_PROGRESS','APPROVED','REJECTED','CANCELLED') NOT NULL DEFAULT 'PENDING',
  `completed_at` timestamp NULL DEFAULT NULL,
  `final_decision` varchar(50) DEFAULT NULL,
  `final_decision_by` bigint(20) UNSIGNED DEFAULT NULL,
  `final_decision_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `universal_approval_instances`
--

INSERT INTO `universal_approval_instances` (`instance_id`, `workflow_id`, `record_id`, `record_type`, `record_number`, `record_title`, `initiated_by`, `initiated_at`, `current_step`, `status`, `completed_at`, `final_decision`, `final_decision_by`, `final_decision_at`, `created_by`, `updated_by`, `deleted_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 1, 4, 'DOCUMENT', 'DOC-0004', 'Seeded DOCUMENT #4', 5, '2026-09-02 04:47:00', 1, 'PENDING', NULL, NULL, NULL, NULL, 5, NULL, NULL, '2026-09-02 04:47:00', '2026-09-02 04:47:00', NULL),
(2, 1, 3, 'DOCUMENT', 'DOC-0003', 'Seeded DOCUMENT #3', 1, '2026-09-01 03:47:00', 2, 'APPROVED', '2026-09-08 03:47:00', 'Approved', 4, '2026-09-08 03:47:00', 1, 4, NULL, '2026-09-01 03:47:00', '2026-09-08 03:47:00', NULL),
(3, 2, 1, 'TRAINING_CURRICULUM', 'TRA-0001', 'Seeded TRAINING_CURRICULUM #1', 2, '2026-08-21 14:47:00', 0, 'IN_PROGRESS', NULL, NULL, NULL, NULL, 2, NULL, NULL, '2026-08-21 14:47:00', '2026-08-21 14:47:00', NULL),
(4, 2, 3, 'TRAINING_CURRICULUM', 'TRA-0003', 'Seeded TRAINING_CURRICULUM #3', 3, '2026-08-14 14:47:00', 0, 'IN_PROGRESS', NULL, NULL, NULL, NULL, 3, NULL, NULL, '2026-08-14 14:47:00', '2026-08-14 14:47:00', NULL);

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

--
-- Table structure for table `universal_approval_notifications`
--

CREATE TABLE `universal_approval_notifications` (
  `notification_id` bigint(20) UNSIGNED NOT NULL,
  `instance_id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `notification_type` varchar(255) NOT NULL,
  `subject` varchar(255) NOT NULL,
  `message` text NOT NULL,
  `is_read` tinyint(1) NOT NULL DEFAULT 0,
  `read_at` timestamp NULL DEFAULT NULL,
  `email_sent` tinyint(1) NOT NULL DEFAULT 0,
  `email_sent_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `universal_approval_notifications`
--

INSERT INTO `universal_approval_notifications` (`notification_id`, `instance_id`, `user_id`, `notification_type`, `subject`, `message`, `is_read`, `read_at`, `email_sent`, `email_sent_at`, `created_by`, `updated_by`, `deleted_by`, `deleted_at`, `created_at`, `updated_at`) VALUES
(1, 1, 5, 'PENDING', 'Approval Required: DOC-0004', 'Your approval is required on step 1 for Seeded DOCUMENT #4.', 0, NULL, 1, '2026-09-09 14:47:00', NULL, NULL, NULL, NULL, '2026-09-02 04:47:00', '2026-09-02 04:47:00'),
(2, 1, 3, 'PENDING', 'Approval Required: DOC-0004', 'Your approval is required on step 1 for Seeded DOCUMENT #4.', 0, NULL, 1, NULL, NULL, NULL, NULL, NULL, '2026-09-02 04:47:00', '2026-09-02 04:47:00'),
(3, 2, 1, 'APPROVED', 'Approved: DOC-0003', 'The record has been fully approved.', 0, NULL, 0, NULL, NULL, NULL, NULL, NULL, '2026-09-01 03:47:00', '2026-09-01 03:47:00'),
(4, 2, 4, 'APPROVED', 'Approved: DOC-0003', 'The record has been fully approved.', 1, '2026-09-10 12:47:00', 0, '2026-09-09 22:47:00', NULL, NULL, NULL, NULL, '2026-09-01 03:47:00', '2026-09-01 03:47:00'),
(5, 3, 2, 'IN_PROGRESS', 'Approval In Progress: TRA-0001', 'Workflow 2 is awaiting further approvals.', 1, '2026-09-10 11:47:00', 0, '2026-09-09 22:47:00', NULL, NULL, NULL, NULL, '2026-08-21 14:47:00', '2026-08-21 14:47:00'),
(6, 4, 3, 'IN_PROGRESS', 'Approval In Progress: TRA-0003', 'Workflow 2 is awaiting further approvals.', 0, NULL, 1, '2026-09-10 00:47:00', NULL, NULL, NULL, NULL, '2026-08-14 14:47:00', '2026-08-14 14:47:00');

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

--
-- Table structure for table `universal_workflows`
--

CREATE TABLE `universal_workflows` (
  `workflow_id` bigint(20) UNSIGNED NOT NULL,
  `workflow_code` varchar(50) DEFAULT NULL,
  `workflow_name` varchar(255) NOT NULL,
  `module_type` varchar(100) DEFAULT NULL,
  `document_type` varchar(100) DEFAULT NULL,
  `variant` varchar(50) DEFAULT NULL COMMENT 'Sub-classification, e.g. STANDARD vs CRITICAL',
  `description` text DEFAULT NULL,
  `is_default` tinyint(1) NOT NULL DEFAULT 0,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `version` int(11) NOT NULL DEFAULT 1,
  `effective_date` date DEFAULT NULL,
  `expiry_date` date DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `universal_workflows`
--

INSERT INTO `universal_workflows` (`workflow_id`, `workflow_code`, `workflow_name`, `module_type`, `document_type`, `variant`, `description`, `is_default`, `is_active`, `version`, `effective_date`, `expiry_date`, `created_by`, `updated_by`, `deleted_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'WF_DOC_001', 'Standard Document Approval', 'DOCUMENT', NULL, NULL, 'Standard workflow for document approval with 3-step process', 1, 1, 1, NULL, NULL, 1, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(2, 'WF_TRAIN_001', 'Training Curriculum Approval', 'TRAINING_CURRICULUM', NULL, NULL, 'Standard workflow for training curriculum approval', 1, 1, 1, NULL, NULL, 1, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL);

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

--
-- Table structure for table `universal_workflow_steps`
--

CREATE TABLE `universal_workflow_steps` (
  `step_id` bigint(20) UNSIGNED NOT NULL,
  `workflow_id` bigint(20) UNSIGNED NOT NULL,
  `step_name` varchar(255) NOT NULL,
  `step_order` int(11) NOT NULL DEFAULT 1,
  `approver_type` varchar(50) NOT NULL DEFAULT 'USER',
  `required_role` varchar(100) DEFAULT NULL,
  `approver_user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `approver_department_id` bigint(20) UNSIGNED DEFAULT NULL,
  `description` text DEFAULT NULL,
  `approval_mode` varchar(50) NOT NULL DEFAULT 'ANY',
  `approval_threshold` decimal(10,2) NOT NULL DEFAULT 1.00,
  `min_approvers` int(11) NOT NULL DEFAULT 1,
  `is_required` tinyint(1) NOT NULL DEFAULT 1,
  `allow_delegation` tinyint(1) NOT NULL DEFAULT 1,
  `allow_rejection` tinyint(1) NOT NULL DEFAULT 1,
  `allow_comments` tinyint(1) NOT NULL DEFAULT 1,
  `allow_attachments` tinyint(1) NOT NULL DEFAULT 0,
  `require_esignature` tinyint(1) NOT NULL DEFAULT 0,
  `due_days` int(11) NOT NULL DEFAULT 5,
  `escalation_enabled` tinyint(1) NOT NULL DEFAULT 0,
  `escalation_hours` int(11) NOT NULL DEFAULT 48,
  `escalation_action` varchar(100) NOT NULL DEFAULT '',
  `escalation_role` varchar(100) DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `universal_workflow_steps`
--

INSERT INTO `universal_workflow_steps` (`step_id`, `workflow_id`, `step_name`, `step_order`, `approver_type`, `required_role`, `approver_user_id`, `approver_department_id`, `description`, `approval_mode`, `approval_threshold`, `min_approvers`, `is_required`, `allow_delegation`, `allow_rejection`, `allow_comments`, `allow_attachments`, `require_esignature`, `due_days`, `escalation_enabled`, `escalation_hours`, `escalation_action`, `escalation_role`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
(1, 1, 'Department Head Review', 1, 'ROLE', 'manager', NULL, NULL, NULL, 'ANY', 1.00, 1, 1, 1, 1, 1, 0, 0, 3, 0, 48, '', NULL, 1, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59'),
(2, 1, 'QA Manager Approval', 2, 'ROLE', 'approver', NULL, NULL, NULL, 'ANY', 1.00, 1, 1, 1, 1, 1, 0, 0, 3, 0, 48, '', NULL, 1, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59');

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

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `email_verified_at` timestamp NULL DEFAULT NULL,
  `password` varchar(255) NOT NULL,
  `phone` varchar(255) DEFAULT NULL,
  `department_id` bigint(20) UNSIGNED DEFAULT NULL,
  `role_id` bigint(20) UNSIGNED DEFAULT NULL,
  `employee_id` bigint(20) UNSIGNED DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `is_deleted` tinyint(1) NOT NULL DEFAULT 0,
  `remember_token` varchar(100) DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `users`
--

INSERT INTO `users` (`id`, `name`, `email`, `email_verified_at`, `password`, `phone`, `department_id`, `role_id`, `employee_id`, `is_active`, `is_deleted`, `remember_token`, `created_by`, `updated_by`, `deleted_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'Super Admin', 'superadmin@qms.com', '2026-09-12 06:46:59', '$2y$12$BMCYvDnV/tWYvFqecTRFkesTPQk5wBeTRUWj5Bhu2037xmXab5zXK', '1234567890', 1, 1, 1, 1, 0, NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(2, 'Admin User', 'admin@qms.com', '2026-09-12 06:46:59', '$2y$12$X.OxC/ssJFHIrrU6CDNFOehp0OIK.E0jEqi3Kg24lsFsVGezDdkfS', '1234567891', 1, 2, 2, 1, 0, NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(3, 'Manager User', 'manager@qms.com', '2026-09-12 06:46:59', '$2y$12$FpgDQLdGLGQ0XxA.j6YdiO9IUzp6ZvLA82mTDwO5LFVHXO7pXyx9m', '1234567892', 4, 3, 3, 1, 0, NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(4, 'Approver User', 'approver@qms.com', '2026-09-12 06:46:59', '$2y$12$B0YTLwZCi/nnpJLLBSV9UOsqzhXeHHw/q9sVvRoLdELBagVsGJe.q', '1234567893', 3, 4, 4, 1, 0, NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(5, 'Regular User', 'user@qms.com', '2026-09-12 06:46:59', '$2y$12$DbCmKmtZ7f2fOiLBEIOUnOEsvVSJh170NEOrITblgeMfV2BXV0cZG', '1234567894', 2, 5, 5, 1, 0, NULL, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL);

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

--
-- Table structure for table `user_roles`
--

CREATE TABLE `user_roles` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `role_id` bigint(20) UNSIGNED NOT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `user_roles`
--

INSERT INTO `user_roles` (`id`, `user_id`, `role_id`, `created_by`, `updated_by`, `deleted_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 1, 1, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(2, 2, 2, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(3, 3, 3, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(4, 4, 4, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL),
(5, 5, 5, NULL, NULL, NULL, '2026-09-12 06:46:59', '2026-09-12 06:46:59', NULL);

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

--
-- Table structure for table `workflow_step_assignees`
--

CREATE TABLE `workflow_step_assignees` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `step_id` bigint(20) UNSIGNED NOT NULL,
  `assignee_type` varchar(255) NOT NULL,
  `assignee_id` bigint(20) UNSIGNED NOT NULL,
  `is_primary` tinyint(1) NOT NULL DEFAULT 0,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `updated_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_by` bigint(20) UNSIGNED DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `approval_delegations`
--
ALTER TABLE `approval_delegations`
  ADD PRIMARY KEY (`delegation_id`),
  ADD KEY `approval_delegations_from_user_id_index` (`from_user_id`),
  ADD KEY `approval_delegations_to_user_id_index` (`to_user_id`),
  ADD KEY `approval_delegations_workflow_id_index` (`workflow_id`),
  ADD KEY `approval_delegations_is_active_index` (`is_active`);

--
-- Indexes for table `assessment_questions`
--
ALTER TABLE `assessment_questions`
  ADD PRIMARY KEY (`question_id`),
  ADD KEY `assessment_questions_assessment_id_index` (`assessment_id`),
  ADD KEY `assessment_questions_topic_id_index` (`topic_id`),
  ADD KEY `assessment_questions_question_type_index` (`question_type`),
  ADD KEY `assessment_questions_display_order_index` (`display_order`),
  ADD KEY `assessment_questions_is_active_index` (`is_active`),
  ADD KEY `assessment_questions_deleted_at_index` (`deleted_at`),
  ADD KEY `assessment_questions_created_by_foreign` (`created_by`),
  ADD KEY `assessment_questions_updated_by_foreign` (`updated_by`),
  ADD KEY `assessment_questions_deleted_by_foreign` (`deleted_by`);

--
-- Indexes for table `audits`
--
ALTER TABLE `audits`
  ADD PRIMARY KEY (`audit_id`),
  ADD UNIQUE KEY `audits_audit_number_unique` (`audit_number`),
  ADD KEY `audits_lead_auditor_id_foreign` (`lead_auditor_id`),
  ADD KEY `audits_auditee_id_foreign` (`auditee_id`),
  ADD KEY `audits_created_by_foreign` (`created_by`),
  ADD KEY `audits_department_id_foreign` (`department_id`),
  ADD KEY `audits_current_status_current_phase_index` (`current_status`,`current_phase`),
  ADD KEY `audits_audit_type_index` (`audit_type`),
  ADD KEY `audits_planned_start_date_index` (`planned_start_date`);

--
-- Indexes for table `audit_audit_trails`
--
ALTER TABLE `audit_audit_trails`
  ADD PRIMARY KEY (`id`),
  ADD KEY `audit_audit_trails_user_id_foreign` (`user_id`),
  ADD KEY `audit_audit_trails_audit_id_changed_at_index` (`audit_id`,`changed_at`);

--
-- Indexes for table `audit_findings`
--
ALTER TABLE `audit_findings`
  ADD PRIMARY KEY (`finding_id`),
  ADD KEY `audit_findings_created_by_foreign` (`created_by`),
  ADD KEY `audit_findings_audit_id_finding_type_index` (`audit_id`,`finding_type`),
  ADD KEY `audit_findings_status_index` (`status`),
  ADD KEY `audit_findings_capa_id_index` (`capa_id`);

--
-- Indexes for table `audit_links`
--
ALTER TABLE `audit_links`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `audit_links_unique` (`audit_id`,`linked_type`,`linked_id`,`relationship`),
  ADD KEY `audit_links_audit_id_linked_type_index` (`audit_id`,`linked_type`);

--
-- Indexes for table `audit_trails`
--
ALTER TABLE `audit_trails`
  ADD PRIMARY KEY (`id`),
  ADD KEY `audit_trails_model_type_model_id_index` (`model_type`,`model_id`),
  ADD KEY `audit_trails_action_index` (`action`),
  ADD KEY `audit_trails_created_at_index` (`created_at`),
  ADD KEY `audit_trails_status_index` (`status`),
  ADD KEY `audit_trails_user_id_index` (`user_id`);

--
-- Indexes for table `branches`
--
ALTER TABLE `branches`
  ADD PRIMARY KEY (`branches_id`),
  ADD UNIQUE KEY `branches_branch_code_unique` (`branch_code`),
  ADD KEY `branches_company_id_index` (`company_id`),
  ADD KEY `branches_status_index` (`status`),
  ADD KEY `branches_is_deleted_index` (`is_deleted`);

--
-- Indexes for table `cache`
--
ALTER TABLE `cache`
  ADD PRIMARY KEY (`key`);

--
-- Indexes for table `cache_locks`
--
ALTER TABLE `cache_locks`
  ADD PRIMARY KEY (`key`);

--
-- Indexes for table `capa_action_plan`
--
ALTER TABLE `capa_action_plan`
  ADD PRIMARY KEY (`action_id`),
  ADD KEY `idx_cap_capa` (`capa_id`),
  ADD KEY `idx_cap_status` (`status`),
  ADD KEY `idx_cap_due` (`due_date`);

--
-- Indexes for table `capa_audit_trails`
--
ALTER TABLE `capa_audit_trails`
  ADD PRIMARY KEY (`audit_id`),
  ADD KEY `idx_cat_capa` (`capa_id`),
  ADD KEY `idx_cat_time` (`changed_at`);

--
-- Indexes for table `capa_closure`
--
ALTER TABLE `capa_closure`
  ADD PRIMARY KEY (`closure_id`),
  ADD KEY `idx_cc_capa` (`capa_id`);

--
-- Indexes for table `capa_documents`
--
ALTER TABLE `capa_documents`
  ADD PRIMARY KEY (`document_id`),
  ADD KEY `idx_cd_capa` (`capa_id`);

--
-- Indexes for table `capa_effectiveness`
--
ALTER TABLE `capa_effectiveness`
  ADD PRIMARY KEY (`effectiveness_id`),
  ADD KEY `idx_ce_capa` (`capa_id`),
  ADD KEY `idx_ce_conclusion` (`conclusion`);

--
-- Indexes for table `capa_extensions`
--
ALTER TABLE `capa_extensions`
  ADD PRIMARY KEY (`extension_id`),
  ADD KEY `idx_cex_capa` (`capa_id`),
  ADD KEY `idx_cex_status` (`approval_status`);

--
-- Indexes for table `capa_investigations`
--
ALTER TABLE `capa_investigations`
  ADD PRIMARY KEY (`investigation_id`),
  ADD KEY `idx_ci_capa` (`capa_id`),
  ADD KEY `idx_ci_status` (`status`);

--
-- Indexes for table `capa_request`
--
ALTER TABLE `capa_request`
  ADD PRIMARY KEY (`capa_id`),
  ADD UNIQUE KEY `capa_request_capa_number_unique` (`capa_number`),
  ADD KEY `idx_capa_status` (`status`),
  ADD KEY `idx_capa_priority` (`priority`),
  ADD KEY `idx_capa_source` (`source_type`,`source_record_id`),
  ADD KEY `idx_capa_owner` (`owner_user_id`),
  ADD KEY `idx_capa_target_date` (`target_completion_date`),
  ADD KEY `idx_capa_workflow` (`workflow_instance_id`),
  ADD KEY `idx_capa_deleted` (`is_deleted`);

--
-- Indexes for table `change_audit_trail`
--
ALTER TABLE `change_audit_trail`
  ADD PRIMARY KEY (`audit_id`),
  ADD KEY `idx_cat_change` (`change_id`),
  ADD KEY `idx_cat_time` (`changed_at`);

--
-- Indexes for table `change_control_links`
--
ALTER TABLE `change_control_links`
  ADD PRIMARY KEY (`link_id`),
  ADD KEY `idx_ccl_polymorphic` (`linked_type`,`linked_id`),
  ADD KEY `idx_ccl_change` (`change_id`);

--
-- Indexes for table `change_control_master`
--
ALTER TABLE `change_control_master`
  ADD PRIMARY KEY (`change_id`),
  ADD UNIQUE KEY `change_control_master_change_number_unique` (`change_number`),
  ADD KEY `idx_cc_type` (`change_type`),
  ADD KEY `idx_cc_status` (`current_status`),
  ADD KEY `idx_cc_phase` (`current_phase`),
  ADD KEY `idx_cc_dept` (`department_id`);

--
-- Indexes for table `change_effectiveness_check`
--
ALTER TABLE `change_effectiveness_check`
  ADD PRIMARY KEY (`effectiveness_id`),
  ADD KEY `idx_cec_change` (`change_id`),
  ADD KEY `idx_cec_conclusion` (`conclusion`);

--
-- Indexes for table `change_impact_assessment`
--
ALTER TABLE `change_impact_assessment`
  ADD PRIMARY KEY (`impact_id`),
  ADD KEY `idx_cia_change` (`change_id`),
  ADD KEY `idx_cia_status` (`approval_status`);

--
-- Indexes for table `change_implementation_plan`
--
ALTER TABLE `change_implementation_plan`
  ADD PRIMARY KEY (`plan_id`),
  ADD KEY `idx_cip_change` (`change_id`),
  ADD KEY `idx_cip_status` (`status`);

--
-- Indexes for table `companies`
--
ALTER TABLE `companies`
  ADD PRIMARY KEY (`companies_id`),
  ADD UNIQUE KEY `companies_company_code_unique` (`company_code`),
  ADD KEY `companies_company_code_index` (`company_code`),
  ADD KEY `companies_status_index` (`status`),
  ADD KEY `companies_is_deleted_index` (`is_deleted`);

--
-- Indexes for table `complaints`
--
ALTER TABLE `complaints`
  ADD PRIMARY KEY (`complaint_id`),
  ADD UNIQUE KEY `complaints_complaint_number_unique` (`complaint_number`),
  ADD KEY `complaints_owner_id_foreign` (`owner_id`),
  ADD KEY `complaints_created_by_foreign` (`created_by`),
  ADD KEY `complaints_department_id_foreign` (`department_id`),
  ADD KEY `complaints_current_status_current_phase_index` (`current_status`,`current_phase`),
  ADD KEY `complaints_is_reportable_index` (`is_reportable`),
  ADD KEY `complaints_received_date_index` (`received_date`);

--
-- Indexes for table `complaint_audit_trails`
--
ALTER TABLE `complaint_audit_trails`
  ADD PRIMARY KEY (`id`),
  ADD KEY `complaint_audit_trails_user_id_foreign` (`user_id`),
  ADD KEY `complaint_audit_trails_complaint_id_changed_at_index` (`complaint_id`,`changed_at`);

--
-- Indexes for table `complaint_links`
--
ALTER TABLE `complaint_links`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `complaint_links_unique` (`complaint_id`,`linked_type`,`linked_id`,`relationship`),
  ADD KEY `complaint_links_complaint_id_linked_type_index` (`complaint_id`,`linked_type`);

--
-- Indexes for table `curriculum_topics`
--
ALTER TABLE `curriculum_topics`
  ADD PRIMARY KEY (`curriculum_topic_id`),
  ADD UNIQUE KEY `curriculum_topics_curriculum_id_topic_id_unique` (`curriculum_id`,`topic_id`),
  ADD KEY `curriculum_topics_sequence_order_index` (`sequence_order`),
  ADD KEY `curriculum_topics_topic_id_foreign` (`topic_id`);

--
-- Indexes for table `departments`
--
ALTER TABLE `departments`
  ADD PRIMARY KEY (`department_id`),
  ADD UNIQUE KEY `departments_department_code_unique` (`department_code`),
  ADD KEY `departments_company_id_index` (`company_id`),
  ADD KEY `departments_branch_id_index` (`branch_id`),
  ADD KEY `departments_status_index` (`status`),
  ADD KEY `departments_department_code_index` (`department_code`),
  ADD KEY `departments_is_deleted_index` (`is_deleted`),
  ADD KEY `departments_manager_id_index` (`manager_id`);

--
-- Indexes for table `deviation_5whys`
--
ALTER TABLE `deviation_5whys`
  ADD PRIMARY KEY (`why_id`),
  ADD KEY `deviation_5whys_root_cause_id_index` (`root_cause_id`);

--
-- Indexes for table `deviation_actions`
--
ALTER TABLE `deviation_actions`
  ADD PRIMARY KEY (`action_id`),
  ADD KEY `deviation_actions_assigned_to_foreign` (`assigned_to`),
  ADD KEY `deviation_actions_verified_by_foreign` (`verified_by`),
  ADD KEY `deviation_actions_deviation_id_index` (`deviation_id`),
  ADD KEY `deviation_actions_status_index` (`status`),
  ADD KEY `deviation_actions_due_date_index` (`due_date`);

--
-- Indexes for table `deviation_affected_items`
--
ALTER TABLE `deviation_affected_items`
  ADD PRIMARY KEY (`affected_id`),
  ADD KEY `deviation_affected_items_disposition_by_foreign` (`disposition_by`),
  ADD KEY `deviation_affected_items_deviation_id_index` (`deviation_id`),
  ADD KEY `deviation_affected_items_batch_number_index` (`batch_number`);

--
-- Indexes for table `deviation_assessments`
--
ALTER TABLE `deviation_assessments`
  ADD PRIMARY KEY (`assessment_id`),
  ADD UNIQUE KEY `deviation_assessments_deviation_id_unique` (`deviation_id`),
  ADD KEY `deviation_assessments_assessed_by_foreign` (`assessed_by`),
  ADD KEY `deviation_assessments_approved_by_foreign` (`approved_by`),
  ADD KEY `deviation_assessments_classification_index` (`classification`),
  ADD KEY `deviation_assessments_risk_priority_index` (`risk_priority`);

--
-- Indexes for table `deviation_audit_trails`
--
ALTER TABLE `deviation_audit_trails`
  ADD PRIMARY KEY (`audit_id`),
  ADD KEY `deviation_audit_trails_changed_by_foreign` (`changed_by`),
  ADD KEY `deviation_audit_trails_deviation_id_index` (`deviation_id`),
  ADD KEY `deviation_audit_trails_changed_at_index` (`changed_at`);

--
-- Indexes for table `deviation_capa_linkages`
--
ALTER TABLE `deviation_capa_linkages`
  ADD PRIMARY KEY (`linkage_id`),
  ADD KEY `deviation_capa_linkages_linked_by_foreign` (`linked_by`),
  ADD KEY `deviation_capa_linkages_deviation_id_index` (`deviation_id`),
  ADD KEY `deviation_capa_linkages_capa_id_index` (`capa_id`),
  ADD KEY `idx_dcl_approval_instance` (`approval_instance_id`);

--
-- Indexes for table `deviation_closures`
--
ALTER TABLE `deviation_closures`
  ADD PRIMARY KEY (`closure_id`),
  ADD KEY `deviation_closures_closure_approved_by_foreign` (`closure_approved_by`),
  ADD KEY `deviation_closures_deviation_id_index` (`deviation_id`);

--
-- Indexes for table `deviation_containments`
--
ALTER TABLE `deviation_containments`
  ADD PRIMARY KEY (`containment_id`),
  ADD KEY `deviation_containments_taken_by_foreign` (`taken_by`),
  ADD KEY `deviation_containments_deviation_id_index` (`deviation_id`);

--
-- Indexes for table `deviation_evidences`
--
ALTER TABLE `deviation_evidences`
  ADD PRIMARY KEY (`evidence_id`),
  ADD KEY `deviation_evidences_uploaded_by_foreign` (`uploaded_by`),
  ADD KEY `deviation_evidences_deviation_id_index` (`deviation_id`),
  ADD KEY `deviation_evidences_evidence_type_index` (`evidence_type`);

--
-- Indexes for table `deviation_findings`
--
ALTER TABLE `deviation_findings`
  ADD PRIMARY KEY (`finding_id`),
  ADD KEY `deviation_findings_created_by_foreign` (`created_by`),
  ADD KEY `deviation_findings_updated_by_foreign` (`updated_by`),
  ADD KEY `deviation_findings_deleted_by_foreign` (`deleted_by`),
  ADD KEY `deviation_findings_investigation_id_index` (`investigation_id`),
  ADD KEY `deviation_findings_finding_type_index` (`finding_type`);

--
-- Indexes for table `deviation_impacts`
--
ALTER TABLE `deviation_impacts`
  ADD PRIMARY KEY (`impact_id`),
  ADD UNIQUE KEY `deviation_impacts_deviation_id_unique` (`deviation_id`),
  ADD KEY `deviation_impacts_assessed_by_foreign` (`assessed_by`);

--
-- Indexes for table `deviation_impact_items`
--
ALTER TABLE `deviation_impact_items`
  ADD PRIMARY KEY (`item_id`),
  ADD KEY `deviation_impact_items_impact_id_index` (`impact_id`),
  ADD KEY `deviation_impact_items_severity_index` (`severity`),
  ADD KEY `deviation_impact_items_mitigation_status_index` (`mitigation_status`);

--
-- Indexes for table `deviation_investigations`
--
ALTER TABLE `deviation_investigations`
  ADD PRIMARY KEY (`investigation_id`),
  ADD KEY `deviation_investigations_investigation_owner_foreign` (`investigation_owner`),
  ADD KEY `deviation_investigations_deviation_id_index` (`deviation_id`),
  ADD KEY `deviation_investigations_status_index` (`status`);

--
-- Indexes for table `deviation_masters`
--
ALTER TABLE `deviation_masters`
  ADD PRIMARY KEY (`deviation_id`),
  ADD UNIQUE KEY `deviation_masters_deviation_number_unique` (`deviation_number`),
  ADD KEY `deviation_masters_discovered_by_foreign` (`discovered_by`),
  ADD KEY `deviation_masters_created_by_foreign` (`created_by`),
  ADD KEY `deviation_masters_updated_by_foreign` (`updated_by`),
  ADD KEY `deviation_masters_deleted_by_foreign` (`deleted_by`),
  ADD KEY `deviation_masters_status_index` (`status`),
  ADD KEY `deviation_masters_current_phase_index` (`current_phase`),
  ADD KEY `deviation_masters_deviation_category_index` (`deviation_category`),
  ADD KEY `deviation_masters_department_id_index` (`department_id`),
  ADD KEY `deviation_masters_discovered_date_index` (`discovered_date`),
  ADD KEY `deviation_masters_deleted_at_index` (`deleted_at`),
  ADD KEY `deviation_masters_record_kind_index` (`record_kind`);

--
-- Indexes for table `deviation_root_causes`
--
ALTER TABLE `deviation_root_causes`
  ADD PRIMARY KEY (`root_cause_id`),
  ADD KEY `deviation_root_causes_confirmed_by_foreign` (`confirmed_by`),
  ADD KEY `deviation_root_causes_investigation_id_index` (`investigation_id`),
  ADD KEY `deviation_root_causes_root_cause_type_index` (`root_cause_type`),
  ADD KEY `deviation_root_causes_is_systemic_index` (`is_systemic`);

--
-- Indexes for table `documents`
--
ALTER TABLE `documents`
  ADD PRIMARY KEY (`document_id`),
  ADD KEY `documents_document_code_index` (`document_code`),
  ADD KEY `documents_source_id_index` (`source_id`),
  ADD KEY `documents_source_type_index` (`source_type`),
  ADD KEY `documents_document_status_index` (`document_status`),
  ADD KEY `documents_created_by_index` (`created_by`),
  ADD KEY `documents_created_at_index` (`created_at`),
  ADD KEY `documents_workflow_instance_id_index` (`workflow_instance_id`),
  ADD KEY `documents_workflow_id_index` (`workflow_id`),
  ADD KEY `documents_current_version_id_index` (`current_version_id`),
  ADD KEY `documents_is_deleted_index` (`is_deleted`);
ALTER TABLE `documents` ADD FULLTEXT KEY `documents_document_title_document_code_document_type_fulltext` (`document_title`,`document_code`,`document_type`);

--
-- Indexes for table `document_acknowledgements`
--
ALTER TABLE `document_acknowledgements`
  ADD PRIMARY KEY (`document_acknowledgements_id`),
  ADD KEY `document_acknowledgements_document_distribution_id_user_id_index` (`document_distribution_id`,`user_id`),
  ADD KEY `document_acknowledgements_status_index` (`status`),
  ADD KEY `document_acknowledgements_acknowledged_at_index` (`acknowledged_at`),
  ADD KEY `document_acknowledgements_user_id_index` (`user_id`);

--
-- Indexes for table `document_distributions`
--
ALTER TABLE `document_distributions`
  ADD PRIMARY KEY (`document_distributions_id`),
  ADD KEY `document_distributions_document_id_document_version_id_index` (`document_id`,`document_version_id`),
  ADD KEY `document_distributions_department_id_index` (`department_id`),
  ADD KEY `document_distributions_user_id_index` (`user_id`),
  ADD KEY `document_distributions_status_index` (`status`);

--
-- Indexes for table `document_reviews`
--
ALTER TABLE `document_reviews`
  ADD PRIMARY KEY (`document_reviews_id`),
  ADD KEY `document_reviews_document_version_id_review_status_index` (`document_version_id`,`review_status`),
  ADD KEY `document_reviews_review_date_index` (`review_date`),
  ADD KEY `document_reviews_reviewer_id_index` (`reviewer_id`);

--
-- Indexes for table `document_versions`
--
ALTER TABLE `document_versions`
  ADD PRIMARY KEY (`document_versions_id`),
  ADD KEY `document_versions_document_id_version_number_index` (`document_id`,`version_number`),
  ADD KEY `document_versions_status_index` (`status`),
  ADD KEY `document_versions_effective_date_index` (`effective_date`),
  ADD KEY `document_versions_prepared_by_index` (`prepared_by`),
  ADD KEY `document_versions_reviewed_by_index` (`reviewed_by`),
  ADD KEY `document_versions_approved_by_index` (`approved_by`);

--
-- Indexes for table `electronic_signatures`
--
ALTER TABLE `electronic_signatures`
  ADD PRIMARY KEY (`electronic_signatures_id`),
  ADD KEY `electronic_signatures_module_id_record_id_index` (`module_id`,`record_id`),
  ADD KEY `electronic_signatures_user_id_index` (`user_id`),
  ADD KEY `electronic_signatures_signature_status_index` (`signature_status`),
  ADD KEY `electronic_signatures_signed_at_index` (`signed_at`);

--
-- Indexes for table `employee`
--
ALTER TABLE `employee`
  ADD PRIMARY KEY (`employee_id`),
  ADD KEY `employee_department_id_index` (`department_id`),
  ADD KEY `employee_employee_email_index` (`employee_email`),
  ADD KEY `employee_employee_names_index` (`employee_names`),
  ADD KEY `employee_is_active_index` (`is_active`),
  ADD KEY `employee_is_deleted_index` (`is_deleted`);

--
-- Indexes for table `employee_competency`
--
ALTER TABLE `employee_competency`
  ADD PRIMARY KEY (`competency_id`),
  ADD UNIQUE KEY `employee_topic_competency_unique` (`employee_id`,`topic_id`),
  ADD KEY `employee_competency_employee_id_index` (`employee_id`),
  ADD KEY `employee_competency_topic_id_index` (`topic_id`),
  ADD KEY `employee_competency_curriculum_id_index` (`curriculum_id`),
  ADD KEY `employee_competency_status_index` (`status`),
  ADD KEY `employee_competency_competency_level_index` (`competency_level`),
  ADD KEY `employee_competency_expiry_date_index` (`expiry_date`),
  ADD KEY `employee_competency_approval_status_index` (`approval_status`),
  ADD KEY `employee_competency_deleted_at_index` (`deleted_at`),
  ADD KEY `employee_competency_training_record_id_foreign` (`training_record_id`),
  ADD KEY `employee_competency_assessed_by_foreign` (`assessed_by`),
  ADD KEY `employee_competency_verified_by_foreign` (`verified_by`),
  ADD KEY `employee_competency_approved_by_foreign` (`approved_by`),
  ADD KEY `employee_competency_created_by_foreign` (`created_by`),
  ADD KEY `employee_competency_updated_by_foreign` (`updated_by`),
  ADD KEY `employee_competency_deleted_by_foreign` (`deleted_by`);

--
-- Indexes for table `escalation_events`
--
ALTER TABLE `escalation_events`
  ADD PRIMARY KEY (`event_id`),
  ADD KEY `escalation_events_notified_user_id_foreign` (`notified_user_id`),
  ADD KEY `escalation_events_subject_type_subject_id_index` (`subject_type`,`subject_id`),
  ADD KEY `escalation_events_rule_id_fired_at_index` (`rule_id`,`fired_at`);

--
-- Indexes for table `escalation_rules`
--
ALTER TABLE `escalation_rules`
  ADD PRIMARY KEY (`rule_id`),
  ADD UNIQUE KEY `escalation_rules_code_unique` (`code`),
  ADD KEY `escalation_rules_parent_rule_id_foreign` (`parent_rule_id`),
  ADD KEY `escalation_rules_created_by_foreign` (`created_by`),
  ADD KEY `escalation_rules_approved_by_foreign` (`approved_by`),
  ADD KEY `escalation_rules_module_condition_type_status_index` (`module`,`condition_type`,`status`);

--
-- Indexes for table `failed_jobs`
--
ALTER TABLE `failed_jobs`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`);

--
-- Indexes for table `jobs`
--
ALTER TABLE `jobs`
  ADD PRIMARY KEY (`id`),
  ADD KEY `jobs_queue_index` (`queue`);

--
-- Indexes for table `job_batches`
--
ALTER TABLE `job_batches`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `lab_sop_definitions`
--
ALTER TABLE `lab_sop_definitions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `lab_sop_definitions_sop_id_foreign` (`sop_id`);

--
-- Indexes for table `lab_sop_distribution`
--
ALTER TABLE `lab_sop_distribution`
  ADD PRIMARY KEY (`id`),
  ADD KEY `lab_sop_distribution_sop_id_foreign` (`sop_id`);

--
-- Indexes for table `lab_sop_documents`
--
ALTER TABLE `lab_sop_documents`
  ADD PRIMARY KEY (`sop_id`),
  ADD KEY `lab_sop_documents_sop_number_index` (`sop_number`),
  ADD KEY `lab_sop_documents_version_index` (`version`);

--
-- Indexes for table `lab_sop_document_control`
--
ALTER TABLE `lab_sop_document_control`
  ADD PRIMARY KEY (`id`),
  ADD KEY `lab_sop_document_control_sop_id_foreign` (`sop_id`);

--
-- Indexes for table `lab_sop_edit_history`
--
ALTER TABLE `lab_sop_edit_history`
  ADD PRIMARY KEY (`history_id`),
  ADD KEY `lab_sop_edit_history_version_id_foreign` (`version_id`),
  ADD KEY `lab_sop_edit_history_edited_by_foreign` (`edited_by`),
  ADD KEY `lab_sop_edit_history_sop_id_edited_at_index` (`sop_id`,`edited_at`);

--
-- Indexes for table `lab_sop_procedures`
--
ALTER TABLE `lab_sop_procedures`
  ADD PRIMARY KEY (`id`),
  ADD KEY `lab_sop_procedures_sop_id_foreign` (`sop_id`);

--
-- Indexes for table `lab_sop_records_access`
--
ALTER TABLE `lab_sop_records_access`
  ADD PRIMARY KEY (`id`),
  ADD KEY `lab_sop_records_access_sop_id_foreign` (`sop_id`);

--
-- Indexes for table `lab_sop_versions`
--
ALTER TABLE `lab_sop_versions`
  ADD PRIMARY KEY (`version_id`),
  ADD KEY `lab_sop_versions_created_by_foreign` (`created_by`),
  ADD KEY `lab_sop_versions_updated_by_foreign` (`updated_by`),
  ADD KEY `lab_sop_versions_sop_id_status_index` (`sop_id`,`status`);

--
-- Indexes for table `migrations`
--
ALTER TABLE `migrations`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `modules`
--
ALTER TABLE `modules`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `modules_name_unique` (`name`),
  ADD KEY `modules_parent_module_index` (`parent_module`);

--
-- Indexes for table `notifications`
--
ALTER TABLE `notifications`
  ADD PRIMARY KEY (`id`),
  ADD KEY `notifications_user_id_is_read_index` (`user_id`,`is_read`),
  ADD KEY `notifications_reference_id_reference_type_index` (`reference_id`,`reference_type`),
  ADD KEY `notifications_priority_index` (`priority`);

--
-- Indexes for table `otps`
--
ALTER TABLE `otps`
  ADD PRIMARY KEY (`id`),
  ADD KEY `otps_user_id_index` (`user_id`);

--
-- Indexes for table `password_reset_tokens`
--
ALTER TABLE `password_reset_tokens`
  ADD PRIMARY KEY (`email`);

--
-- Indexes for table `permissions`
--
ALTER TABLE `permissions`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `permissions_name_unique` (`name`),
  ADD KEY `permissions_module_action_index` (`module`,`action`);

--
-- Indexes for table `qms_trainings`
--
ALTER TABLE `qms_trainings`
  ADD PRIMARY KEY (`training_id`),
  ADD UNIQUE KEY `qms_trainings_training_code_unique` (`training_code`),
  ADD KEY `qms_trainings_training_code_index` (`training_code`),
  ADD KEY `qms_trainings_topic_id_index` (`topic_id`),
  ADD KEY `qms_trainings_curriculum_id_index` (`curriculum_id`),
  ADD KEY `qms_trainings_requirement_id_index` (`requirement_id`),
  ADD KEY `qms_trainings_document_id_index` (`document_id`),
  ADD KEY `qms_trainings_employee_id_index` (`employee_id`),
  ADD KEY `qms_trainings_trainer_id_index` (`trainer_id`),
  ADD KEY `qms_trainings_status_index` (`status`),
  ADD KEY `qms_trainings_due_date_index` (`due_date`),
  ADD KEY `qms_trainings_assignment_method_index` (`assignment_method`),
  ADD KEY `qms_trainings_certificate_expiry_index` (`certificate_expiry`),
  ADD KEY `qms_trainings_deleted_at_index` (`deleted_at`),
  ADD KEY `qms_trainings_effectiveness_evaluated_by_foreign` (`effectiveness_evaluated_by`),
  ADD KEY `qms_trainings_created_by_foreign` (`created_by`),
  ADD KEY `qms_trainings_updated_by_foreign` (`updated_by`),
  ADD KEY `qms_trainings_deleted_by_foreign` (`deleted_by`),
  ADD KEY `qms_trainings_current_schedule_fk` (`current_schedule_id`);

--
-- Indexes for table `qms_training_materials`
--
ALTER TABLE `qms_training_materials`
  ADD PRIMARY KEY (`material_id`),
  ADD KEY `qms_training_materials_topic_id_index` (`topic_id`),
  ADD KEY `qms_training_materials_curriculum_id_index` (`curriculum_id`),
  ADD KEY `qms_training_materials_document_id_index` (`document_id`),
  ADD KEY `qms_training_materials_material_type_index` (`material_type`),
  ADD KEY `qms_training_materials_display_order_index` (`display_order`),
  ADD KEY `qms_training_materials_is_active_index` (`is_active`),
  ADD KEY `qms_training_materials_deleted_at_index` (`deleted_at`),
  ADD KEY `qms_training_materials_created_by_foreign` (`created_by`),
  ADD KEY `qms_training_materials_updated_by_foreign` (`updated_by`),
  ADD KEY `qms_training_materials_deleted_by_foreign` (`deleted_by`);

--
-- Indexes for table `question_options`
--
ALTER TABLE `question_options`
  ADD PRIMARY KEY (`option_id`),
  ADD KEY `question_options_question_id_index` (`question_id`),
  ADD KEY `question_options_is_correct_index` (`is_correct`),
  ADD KEY `question_options_display_order_index` (`display_order`);

--
-- Indexes for table `record_links`
--
ALTER TABLE `record_links`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `record_links_unique` (`source_type`,`source_id`,`target_type`,`target_id`,`relationship`),
  ADD KEY `record_links_created_by_foreign` (`created_by`),
  ADD KEY `record_links_source_idx` (`source_type`,`source_id`),
  ADD KEY `record_links_target_idx` (`target_type`,`target_id`);

--
-- Indexes for table `risk_assessments`
--
ALTER TABLE `risk_assessments`
  ADD PRIMARY KEY (`assessment_id`),
  ADD UNIQUE KEY `risk_assessments_assessment_number_unique` (`assessment_number`),
  ADD KEY `risk_assessments_assessor_id_foreign` (`assessor_id`),
  ADD KEY `risk_assessments_approved_by_foreign` (`approved_by`),
  ADD KEY `risk_assessments_created_by_foreign` (`created_by`),
  ADD KEY `assessable_index` (`assessable_type`,`assessable_id`),
  ADD KEY `risk_assessments_template_id_status_index` (`template_id`,`status`),
  ADD KEY `risk_assessments_outcome_index` (`outcome`);

--
-- Indexes for table `risk_assessment_audit_trails`
--
ALTER TABLE `risk_assessment_audit_trails`
  ADD PRIMARY KEY (`id`),
  ADD KEY `risk_assessment_audit_trails_user_id_foreign` (`user_id`),
  ADD KEY `risk_assessment_audit_trails_assessment_id_changed_at_index` (`assessment_id`,`changed_at`);

--
-- Indexes for table `risk_assessment_items`
--
ALTER TABLE `risk_assessment_items`
  ADD PRIMARY KEY (`item_id`),
  ADD KEY `risk_assessment_items_action_owner_id_foreign` (`action_owner_id`),
  ADD KEY `risk_assessment_items_assessment_id_item_order_index` (`assessment_id`,`item_order`),
  ADD KEY `risk_assessment_items_rpn_index` (`rpn`),
  ADD KEY `risk_assessment_items_risk_level_index` (`risk_level`);

--
-- Indexes for table `risk_assessment_links`
--
ALTER TABLE `risk_assessment_links`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `risk_links_unique` (`assessment_id`,`linked_type`,`linked_id`,`relationship`),
  ADD KEY `risk_assessment_links_assessment_id_linked_type_index` (`assessment_id`,`linked_type`);

--
-- Indexes for table `risk_assessment_templates`
--
ALTER TABLE `risk_assessment_templates`
  ADD PRIMARY KEY (`template_id`),
  ADD UNIQUE KEY `risk_assessment_templates_template_code_unique` (`template_code`),
  ADD KEY `risk_assessment_templates_parent_template_id_foreign` (`parent_template_id`),
  ADD KEY `risk_assessment_templates_created_by_foreign` (`created_by`),
  ADD KEY `risk_assessment_templates_approved_by_foreign` (`approved_by`),
  ADD KEY `risk_assessment_templates_scope_status_index` (`scope`,`status`),
  ADD KEY `risk_assessment_templates_template_type_index` (`template_type`);

--
-- Indexes for table `risk_assessment_template_fields`
--
ALTER TABLE `risk_assessment_template_fields`
  ADD PRIMARY KEY (`field_id`),
  ADD UNIQUE KEY `template_field_key_unique` (`template_id`,`field_key`),
  ADD KEY `risk_assessment_template_fields_template_id_display_order_index` (`template_id`,`display_order`);

--
-- Indexes for table `roles`
--
ALTER TABLE `roles`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `roles_name_unique` (`name`);

--
-- Indexes for table `role_curricula`
--
ALTER TABLE `role_curricula`
  ADD PRIMARY KEY (`role_curriculum_id`),
  ADD UNIQUE KEY `role_curricula_role_id_curriculum_id_unique` (`role_id`,`curriculum_id`),
  ADD KEY `role_curricula_curriculum_id_foreign` (`curriculum_id`),
  ADD KEY `role_curricula_created_by_foreign` (`created_by`);

--
-- Indexes for table `role_permissions`
--
ALTER TABLE `role_permissions`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `role_permissions_role_id_permission_id_unique` (`role_id`,`permission_id`),
  ADD KEY `role_permissions_role_id_index` (`role_id`),
  ADD KEY `role_permissions_permission_id_index` (`permission_id`);

--
-- Indexes for table `sessions`
--
ALTER TABLE `sessions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `sessions_user_id_index` (`user_id`),
  ADD KEY `sessions_last_activity_index` (`last_activity`);

--
-- Indexes for table `suppliers`
--
ALTER TABLE `suppliers`
  ADD PRIMARY KEY (`supplier_id`),
  ADD UNIQUE KEY `suppliers_supplier_code_unique` (`supplier_code`),
  ADD KEY `suppliers_owner_id_foreign` (`owner_id`),
  ADD KEY `suppliers_created_by_foreign` (`created_by`),
  ADD KEY `suppliers_current_status_current_phase_index` (`current_status`,`current_phase`),
  ADD KEY `suppliers_supplier_type_index` (`supplier_type`),
  ADD KEY `suppliers_risk_classification_index` (`risk_classification`),
  ADD KEY `suppliers_next_requalification_date_index` (`next_requalification_date`);

--
-- Indexes for table `supplier_audit_trails`
--
ALTER TABLE `supplier_audit_trails`
  ADD PRIMARY KEY (`id`),
  ADD KEY `supplier_audit_trails_user_id_foreign` (`user_id`),
  ADD KEY `supplier_audit_trails_supplier_id_changed_at_index` (`supplier_id`,`changed_at`);

--
-- Indexes for table `supplier_links`
--
ALTER TABLE `supplier_links`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `supplier_links_unique` (`supplier_id`,`linked_type`,`linked_id`,`relationship`),
  ADD KEY `supplier_links_supplier_id_linked_type_index` (`supplier_id`,`linked_type`);

--
-- Indexes for table `supplier_qualifications`
--
ALTER TABLE `supplier_qualifications`
  ADD PRIMARY KEY (`qualification_id`),
  ADD KEY `supplier_qualifications_assessor_id_foreign` (`assessor_id`),
  ADD KEY `supplier_qualifications_created_by_foreign` (`created_by`),
  ADD KEY `supplier_qualifications_supplier_id_status_index` (`supplier_id`,`status`),
  ADD KEY `supplier_qualifications_qualification_type_index` (`qualification_type`),
  ADD KEY `supplier_qualifications_valid_until_index` (`valid_until`);

--
-- Indexes for table `training_acknowledgements`
--
ALTER TABLE `training_acknowledgements`
  ADD PRIMARY KEY (`acknowledgement_id`),
  ADD UNIQUE KEY `ack_training_employee_material_unique` (`training_id`,`employee_id`,`material_id`),
  ADD KEY `training_acknowledgements_training_id_index` (`training_id`),
  ADD KEY `training_acknowledgements_employee_id_index` (`employee_id`),
  ADD KEY `training_acknowledgements_material_id_index` (`material_id`),
  ADD KEY `training_acknowledgements_is_valid_index` (`is_valid`),
  ADD KEY `training_acknowledgements_acknowledged_at_index` (`acknowledged_at`),
  ADD KEY `training_acknowledgements_deleted_at_index` (`deleted_at`),
  ADD KEY `training_acknowledgements_revoked_by_foreign` (`revoked_by`),
  ADD KEY `training_acknowledgements_deleted_by_foreign` (`deleted_by`);

--
-- Indexes for table `training_assessments`
--
ALTER TABLE `training_assessments`
  ADD PRIMARY KEY (`assessment_id`),
  ADD KEY `training_assessments_topic_id_index` (`topic_id`),
  ADD KEY `training_assessments_curriculum_id_index` (`curriculum_id`),
  ADD KEY `training_assessments_assessment_type_index` (`assessment_type`),
  ADD KEY `training_assessments_is_active_index` (`is_active`),
  ADD KEY `training_assessments_deleted_at_index` (`deleted_at`),
  ADD KEY `training_assessments_created_by_foreign` (`created_by`),
  ADD KEY `training_assessments_updated_by_foreign` (`updated_by`),
  ADD KEY `training_assessments_deleted_by_foreign` (`deleted_by`);

--
-- Indexes for table `training_assessment_answers`
--
ALTER TABLE `training_assessment_answers`
  ADD PRIMARY KEY (`answer_id`),
  ADD KEY `training_assessment_answers_result_id_index` (`result_id`),
  ADD KEY `training_assessment_answers_question_id_index` (`question_id`),
  ADD KEY `training_assessment_answers_is_correct_index` (`is_correct`),
  ADD KEY `training_assessment_answers_selected_option_id_foreign` (`selected_option_id`);

--
-- Indexes for table `training_assessment_results`
--
ALTER TABLE `training_assessment_results`
  ADD PRIMARY KEY (`result_id`),
  ADD KEY `training_assessment_results_training_id_index` (`training_id`),
  ADD KEY `training_assessment_results_assessment_id_index` (`assessment_id`),
  ADD KEY `training_assessment_results_employee_id_index` (`employee_id`),
  ADD KEY `training_assessment_results_is_passed_index` (`is_passed`),
  ADD KEY `training_assessment_results_completed_at_index` (`completed_at`),
  ADD KEY `training_assessment_results_deleted_at_index` (`deleted_at`),
  ADD KEY `training_assessment_results_reviewed_by_foreign` (`reviewed_by`);

--
-- Indexes for table `training_attendance`
--
ALTER TABLE `training_attendance`
  ADD PRIMARY KEY (`attendance_id`),
  ADD UNIQUE KEY `attendance_training_employee_unique` (`training_id`,`employee_id`),
  ADD KEY `training_attendance_training_id_index` (`training_id`),
  ADD KEY `training_attendance_schedule_id_index` (`schedule_id`),
  ADD KEY `training_attendance_employee_id_index` (`employee_id`),
  ADD KEY `training_attendance_attendance_date_index` (`attendance_date`),
  ADD KEY `training_attendance_status_index` (`status`),
  ADD KEY `training_attendance_deleted_at_index` (`deleted_at`),
  ADD KEY `training_attendance_recorded_by_foreign` (`recorded_by`),
  ADD KEY `training_attendance_updated_by_foreign` (`updated_by`),
  ADD KEY `training_attendance_deleted_by_foreign` (`deleted_by`);

--
-- Indexes for table `training_categories`
--
ALTER TABLE `training_categories`
  ADD PRIMARY KEY (`category_id`),
  ADD UNIQUE KEY `training_categories_category_code_unique` (`category_code`),
  ADD KEY `training_categories_category_code_index` (`category_code`),
  ADD KEY `training_categories_is_active_index` (`is_active`),
  ADD KEY `training_categories_deleted_at_index` (`deleted_at`),
  ADD KEY `training_categories_created_by_foreign` (`created_by`),
  ADD KEY `training_categories_updated_by_foreign` (`updated_by`),
  ADD KEY `training_categories_deleted_by_foreign` (`deleted_by`);

--
-- Indexes for table `training_certificates`
--
ALTER TABLE `training_certificates`
  ADD PRIMARY KEY (`certificate_id`),
  ADD UNIQUE KEY `training_certificates_certificate_number_unique` (`certificate_number`),
  ADD UNIQUE KEY `training_certificates_verification_code_unique` (`verification_code`),
  ADD KEY `training_certificates_certificate_number_index` (`certificate_number`),
  ADD KEY `training_certificates_verification_code_index` (`verification_code`),
  ADD KEY `training_certificates_employee_id_index` (`employee_id`),
  ADD KEY `training_certificates_training_id_index` (`training_id`),
  ADD KEY `training_certificates_topic_id_index` (`topic_id`),
  ADD KEY `training_certificates_status_index` (`status`),
  ADD KEY `training_certificates_issue_date_index` (`issue_date`),
  ADD KEY `training_certificates_expiry_date_index` (`expiry_date`),
  ADD KEY `training_certificates_deleted_at_index` (`deleted_at`),
  ADD KEY `training_certificates_competency_id_foreign` (`competency_id`),
  ADD KEY `training_certificates_curriculum_id_foreign` (`curriculum_id`),
  ADD KEY `training_certificates_issued_by_foreign` (`issued_by`),
  ADD KEY `training_certificates_revoked_by_foreign` (`revoked_by`),
  ADD KEY `training_certificates_created_by_foreign` (`created_by`),
  ADD KEY `training_certificates_updated_by_foreign` (`updated_by`),
  ADD KEY `training_certificates_deleted_by_foreign` (`deleted_by`);

--
-- Indexes for table `training_curricula`
--
ALTER TABLE `training_curricula`
  ADD PRIMARY KEY (`curriculum_id`),
  ADD UNIQUE KEY `training_curricula_curriculum_code_unique` (`curriculum_code`),
  ADD KEY `training_curricula_curriculum_code_index` (`curriculum_code`),
  ADD KEY `training_curricula_is_onboarding_index` (`is_onboarding`),
  ADD KEY `training_curricula_approval_status_index` (`approval_status`),
  ADD KEY `training_curricula_is_active_index` (`is_active`),
  ADD KEY `training_curricula_deleted_at_index` (`deleted_at`),
  ADD KEY `training_curricula_workflow_instance_id_index` (`workflow_instance_id`),
  ADD KEY `training_curricula_approved_by_foreign` (`approved_by`),
  ADD KEY `training_curricula_created_by_foreign` (`created_by`),
  ADD KEY `training_curricula_updated_by_foreign` (`updated_by`),
  ADD KEY `training_curricula_deleted_by_foreign` (`deleted_by`);

--
-- Indexes for table `training_effectiveness`
--
ALTER TABLE `training_effectiveness`
  ADD PRIMARY KEY (`effectiveness_id`),
  ADD KEY `training_effectiveness_training_id_index` (`training_id`),
  ADD KEY `training_effectiveness_employee_id_index` (`employee_id`),
  ADD KEY `training_effectiveness_evaluation_type_index` (`evaluation_type`),
  ADD KEY `training_effectiveness_effectiveness_status_index` (`effectiveness_status`),
  ADD KEY `training_effectiveness_evaluation_date_index` (`evaluation_date`),
  ADD KEY `training_effectiveness_deleted_at_index` (`deleted_at`),
  ADD KEY `training_effectiveness_monitored_by_foreign` (`monitored_by`),
  ADD KEY `training_effectiveness_created_by_foreign` (`created_by`),
  ADD KEY `training_effectiveness_updated_by_foreign` (`updated_by`),
  ADD KEY `training_effectiveness_deleted_by_foreign` (`deleted_by`);

--
-- Indexes for table `training_escalation_log`
--
ALTER TABLE `training_escalation_log`
  ADD PRIMARY KEY (`id`),
  ADD KEY `training_escalation_log_training_id_index` (`training_id`),
  ADD KEY `training_escalation_log_employee_id_index` (`employee_id`),
  ADD KEY `training_escalation_log_escalated_at_index` (`escalated_at`),
  ADD KEY `training_escalation_level_idx` (`training_id`,`escalation_level`),
  ADD KEY `training_escalation_log_escalated_to_foreign` (`escalated_to`);

--
-- Indexes for table `training_notifications`
--
ALTER TABLE `training_notifications`
  ADD PRIMARY KEY (`notification_id`),
  ADD KEY `training_notifications_user_id_is_read_index` (`user_id`,`is_read`),
  ADD KEY `training_notifications_notification_type_index` (`notification_type`),
  ADD KEY `training_notifications_priority_index` (`priority`),
  ADD KEY `training_notifications_training_id_index` (`training_id`),
  ADD KEY `training_notifications_created_at_index` (`created_at`),
  ADD KEY `training_notifications_scheduled_for_index` (`scheduled_for`),
  ADD KEY `training_notifications_escalated_to_user_id_index` (`escalated_to_user_id`);

--
-- Indexes for table `training_requirements`
--
ALTER TABLE `training_requirements`
  ADD PRIMARY KEY (`requirement_id`),
  ADD UNIQUE KEY `training_requirements_requirement_code_unique` (`requirement_code`),
  ADD KEY `training_requirements_requirement_code_index` (`requirement_code`),
  ADD KEY `training_requirements_trigger_type_index` (`trigger_type`),
  ADD KEY `training_requirements_status_index` (`status`),
  ADD KEY `training_requirements_priority_index` (`priority`),
  ADD KEY `training_requirements_due_date_index` (`due_date`),
  ADD KEY `training_requirements_approval_status_index` (`approval_status`),
  ADD KEY `training_requirements_deleted_at_index` (`deleted_at`),
  ADD KEY `training_requirements_workflow_instance_id_index` (`workflow_instance_id`),
  ADD KEY `training_requirements_topic_id_foreign` (`topic_id`),
  ADD KEY `training_requirements_curriculum_id_foreign` (`curriculum_id`),
  ADD KEY `training_requirements_approved_by_foreign` (`approved_by`),
  ADD KEY `training_requirements_created_by_foreign` (`created_by`),
  ADD KEY `training_requirements_updated_by_foreign` (`updated_by`),
  ADD KEY `training_requirements_deleted_by_foreign` (`deleted_by`);

--
-- Indexes for table `training_reschedule_log`
--
ALTER TABLE `training_reschedule_log`
  ADD PRIMARY KEY (`log_id`),
  ADD KEY `training_reschedule_log_training_id_index` (`training_id`),
  ADD KEY `training_reschedule_log_schedule_id_index` (`schedule_id`),
  ADD KEY `training_reschedule_log_rescheduled_at_index` (`rescheduled_at`),
  ADD KEY `training_reschedule_log_rescheduled_by_foreign` (`rescheduled_by`);

--
-- Indexes for table `training_schedules`
--
ALTER TABLE `training_schedules`
  ADD PRIMARY KEY (`schedule_id`),
  ADD KEY `training_schedules_training_id_index` (`training_id`),
  ADD KEY `training_schedules_scheduled_date_index` (`scheduled_date`),
  ADD KEY `training_schedules_status_index` (`status`),
  ADD KEY `training_schedules_trainer_id_index` (`trainer_id`),
  ADD KEY `training_schedules_deleted_at_index` (`deleted_at`),
  ADD KEY `training_schedules_co_trainer_id_foreign` (`co_trainer_id`),
  ADD KEY `training_schedules_created_by_foreign` (`created_by`),
  ADD KEY `training_schedules_updated_by_foreign` (`updated_by`),
  ADD KEY `training_schedules_deleted_by_foreign` (`deleted_by`);

--
-- Indexes for table `training_topics`
--
ALTER TABLE `training_topics`
  ADD PRIMARY KEY (`topic_id`),
  ADD UNIQUE KEY `training_topics_topic_code_unique` (`topic_code`),
  ADD KEY `training_topics_topic_code_index` (`topic_code`),
  ADD KEY `training_topics_category_id_index` (`category_id`),
  ADD KEY `training_topics_is_active_index` (`is_active`),
  ADD KEY `training_topics_document_id_index` (`document_id`),
  ADD KEY `training_topics_deleted_at_index` (`deleted_at`),
  ADD KEY `training_topics_created_by_foreign` (`created_by`),
  ADD KEY `training_topics_updated_by_foreign` (`updated_by`),
  ADD KEY `training_topics_deleted_by_foreign` (`deleted_by`);

--
-- Indexes for table `universal_approval_actions`
--
ALTER TABLE `universal_approval_actions`
  ADD PRIMARY KEY (`action_id`),
  ADD KEY `universal_approval_actions_instance_id_index` (`instance_id`),
  ADD KEY `universal_approval_actions_step_id_index` (`step_id`),
  ADD KEY `universal_approval_actions_approver_user_id_index` (`approver_user_id`),
  ADD KEY `universal_approval_actions_action_index` (`action`);

--
-- Indexes for table `universal_approval_attachments`
--
ALTER TABLE `universal_approval_attachments`
  ADD PRIMARY KEY (`attachment_id`),
  ADD KEY `universal_approval_attachments_uploaded_by_foreign` (`uploaded_by`),
  ADD KEY `universal_approval_attachments_created_by_foreign` (`created_by`),
  ADD KEY `universal_approval_attachments_updated_by_foreign` (`updated_by`),
  ADD KEY `universal_approval_attachments_deleted_by_foreign` (`deleted_by`),
  ADD KEY `attach_action_idx` (`action_id`);

--
-- Indexes for table `universal_approval_delegations`
--
ALTER TABLE `universal_approval_delegations`
  ADD PRIMARY KEY (`delegation_id`),
  ADD KEY `universal_approval_delegations_delegated_user_id_foreign` (`delegated_user_id`),
  ADD KEY `universal_approval_delegations_workflow_id_foreign` (`workflow_id`),
  ADD KEY `universal_approval_delegations_created_by_foreign` (`created_by`),
  ADD KEY `universal_approval_delegations_updated_by_foreign` (`updated_by`),
  ADD KEY `universal_approval_delegations_deleted_by_foreign` (`deleted_by`),
  ADD KEY `universal_approval_delegations_cancelled_by_foreign` (`cancelled_by`),
  ADD KEY `deleg_orig_deleg_idx` (`original_user_id`,`delegated_user_id`),
  ADD KEY `deleg_status_idx` (`status`);

--
-- Indexes for table `universal_approval_instances`
--
ALTER TABLE `universal_approval_instances`
  ADD PRIMARY KEY (`instance_id`),
  ADD KEY `universal_approval_instances_workflow_id_index` (`workflow_id`),
  ADD KEY `universal_approval_instances_record_type_index` (`record_type`),
  ADD KEY `universal_approval_instances_record_id_index` (`record_id`),
  ADD KEY `universal_approval_instances_status_index` (`status`),
  ADD KEY `universal_approval_instances_initiated_by_index` (`initiated_by`);

--
-- Indexes for table `universal_approval_notifications`
--
ALTER TABLE `universal_approval_notifications`
  ADD PRIMARY KEY (`notification_id`),
  ADD KEY `universal_approval_notifications_instance_id_foreign` (`instance_id`),
  ADD KEY `universal_approval_notifications_created_by_foreign` (`created_by`),
  ADD KEY `universal_approval_notifications_updated_by_foreign` (`updated_by`),
  ADD KEY `universal_approval_notifications_deleted_by_foreign` (`deleted_by`),
  ADD KEY `notif_user_read_idx` (`user_id`,`is_read`);

--
-- Indexes for table `universal_workflows`
--
ALTER TABLE `universal_workflows`
  ADD PRIMARY KEY (`workflow_id`),
  ADD KEY `universal_workflows_workflow_code_index` (`workflow_code`),
  ADD KEY `universal_workflows_module_type_index` (`module_type`),
  ADD KEY `universal_workflows_is_default_index` (`is_default`),
  ADD KEY `universal_workflows_is_active_index` (`is_active`);

--
-- Indexes for table `universal_workflow_steps`
--
ALTER TABLE `universal_workflow_steps`
  ADD PRIMARY KEY (`step_id`),
  ADD KEY `universal_workflow_steps_workflow_id_index` (`workflow_id`),
  ADD KEY `universal_workflow_steps_step_order_index` (`step_order`);

--
-- Indexes for table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `users_email_unique` (`email`),
  ADD KEY `users_is_deleted_index` (`is_deleted`);

--
-- Indexes for table `user_roles`
--
ALTER TABLE `user_roles`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `user_roles_user_id_role_id_unique` (`user_id`,`role_id`),
  ADD KEY `user_roles_user_id_index` (`user_id`),
  ADD KEY `user_roles_role_id_index` (`role_id`);

--
-- Indexes for table `workflow_step_assignees`
--
ALTER TABLE `workflow_step_assignees`
  ADD PRIMARY KEY (`id`),
  ADD KEY `workflow_step_assignees_step_id_foreign` (`step_id`),
  ADD KEY `workflow_step_assignees_created_by_foreign` (`created_by`),
  ADD KEY `workflow_step_assignees_updated_by_foreign` (`updated_by`),
  ADD KEY `workflow_step_assignees_deleted_by_foreign` (`deleted_by`),
  ADD KEY `assignee_type_id_idx` (`assignee_type`,`assignee_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `approval_delegations`
--
ALTER TABLE `approval_delegations`
  MODIFY `delegation_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `assessment_questions`
--
ALTER TABLE `assessment_questions`
  MODIFY `question_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `audits`
--
ALTER TABLE `audits`
  MODIFY `audit_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `audit_audit_trails`
--
ALTER TABLE `audit_audit_trails`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;

--
-- AUTO_INCREMENT for table `audit_findings`
--
ALTER TABLE `audit_findings`
  MODIFY `finding_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;

--
-- AUTO_INCREMENT for table `audit_links`
--
ALTER TABLE `audit_links`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `audit_trails`
--
ALTER TABLE `audit_trails`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23;

--
-- AUTO_INCREMENT for table `branches`
--
ALTER TABLE `branches`
  MODIFY `branches_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `capa_action_plan`
--
ALTER TABLE `capa_action_plan`
  MODIFY `action_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `capa_audit_trails`
--
ALTER TABLE `capa_audit_trails`
  MODIFY `audit_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `capa_closure`
--
ALTER TABLE `capa_closure`
  MODIFY `closure_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `capa_documents`
--
ALTER TABLE `capa_documents`
  MODIFY `document_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `capa_effectiveness`
--
ALTER TABLE `capa_effectiveness`
  MODIFY `effectiveness_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `capa_extensions`
--
ALTER TABLE `capa_extensions`
  MODIFY `extension_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `capa_investigations`
--
ALTER TABLE `capa_investigations`
  MODIFY `investigation_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `capa_request`
--
ALTER TABLE `capa_request`
  MODIFY `capa_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `change_audit_trail`
--
ALTER TABLE `change_audit_trail`
  MODIFY `audit_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `change_control_links`
--
ALTER TABLE `change_control_links`
  MODIFY `link_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `change_control_master`
--
ALTER TABLE `change_control_master`
  MODIFY `change_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `change_effectiveness_check`
--
ALTER TABLE `change_effectiveness_check`
  MODIFY `effectiveness_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `change_impact_assessment`
--
ALTER TABLE `change_impact_assessment`
  MODIFY `impact_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `change_implementation_plan`
--
ALTER TABLE `change_implementation_plan`
  MODIFY `plan_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `companies`
--
ALTER TABLE `companies`
  MODIFY `companies_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `complaints`
--
ALTER TABLE `complaints`
  MODIFY `complaint_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `complaint_audit_trails`
--
ALTER TABLE `complaint_audit_trails`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23;

--
-- AUTO_INCREMENT for table `complaint_links`
--
ALTER TABLE `complaint_links`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `curriculum_topics`
--
ALTER TABLE `curriculum_topics`
  MODIFY `curriculum_topic_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `departments`
--
ALTER TABLE `departments`
  MODIFY `department_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `deviation_5whys`
--
ALTER TABLE `deviation_5whys`
  MODIFY `why_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `deviation_actions`
--
ALTER TABLE `deviation_actions`
  MODIFY `action_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `deviation_affected_items`
--
ALTER TABLE `deviation_affected_items`
  MODIFY `affected_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `deviation_assessments`
--
ALTER TABLE `deviation_assessments`
  MODIFY `assessment_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `deviation_audit_trails`
--
ALTER TABLE `deviation_audit_trails`
  MODIFY `audit_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `deviation_capa_linkages`
--
ALTER TABLE `deviation_capa_linkages`
  MODIFY `linkage_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `deviation_closures`
--
ALTER TABLE `deviation_closures`
  MODIFY `closure_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `deviation_containments`
--
ALTER TABLE `deviation_containments`
  MODIFY `containment_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `deviation_evidences`
--
ALTER TABLE `deviation_evidences`
  MODIFY `evidence_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `deviation_findings`
--
ALTER TABLE `deviation_findings`
  MODIFY `finding_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `deviation_impacts`
--
ALTER TABLE `deviation_impacts`
  MODIFY `impact_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `deviation_impact_items`
--
ALTER TABLE `deviation_impact_items`
  MODIFY `item_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `deviation_investigations`
--
ALTER TABLE `deviation_investigations`
  MODIFY `investigation_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `deviation_masters`
--
ALTER TABLE `deviation_masters`
  MODIFY `deviation_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `deviation_root_causes`
--
ALTER TABLE `deviation_root_causes`
  MODIFY `root_cause_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `documents`
--
ALTER TABLE `documents`
  MODIFY `document_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;

--
-- AUTO_INCREMENT for table `document_acknowledgements`
--
ALTER TABLE `document_acknowledgements`
  MODIFY `document_acknowledgements_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;

--
-- AUTO_INCREMENT for table `document_distributions`
--
ALTER TABLE `document_distributions`
  MODIFY `document_distributions_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;

--
-- AUTO_INCREMENT for table `document_reviews`
--
ALTER TABLE `document_reviews`
  MODIFY `document_reviews_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;

--
-- AUTO_INCREMENT for table `document_versions`
--
ALTER TABLE `document_versions`
  MODIFY `document_versions_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;

--
-- AUTO_INCREMENT for table `electronic_signatures`
--
ALTER TABLE `electronic_signatures`
  MODIFY `electronic_signatures_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21;

--
-- AUTO_INCREMENT for table `employee`
--
ALTER TABLE `employee`
  MODIFY `employee_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;

--
-- AUTO_INCREMENT for table `employee_competency`
--
ALTER TABLE `employee_competency`
  MODIFY `competency_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `escalation_events`
--
ALTER TABLE `escalation_events`
  MODIFY `event_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `escalation_rules`
--
ALTER TABLE `escalation_rules`
  MODIFY `rule_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `failed_jobs`
--
ALTER TABLE `failed_jobs`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `jobs`
--
ALTER TABLE `jobs`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `lab_sop_definitions`
--
ALTER TABLE `lab_sop_definitions`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `lab_sop_distribution`
--
ALTER TABLE `lab_sop_distribution`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `lab_sop_documents`
--
ALTER TABLE `lab_sop_documents`
  MODIFY `sop_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `lab_sop_document_control`
--
ALTER TABLE `lab_sop_document_control`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `lab_sop_edit_history`
--
ALTER TABLE `lab_sop_edit_history`
  MODIFY `history_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `lab_sop_procedures`
--
ALTER TABLE `lab_sop_procedures`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `lab_sop_records_access`
--
ALTER TABLE `lab_sop_records_access`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `lab_sop_versions`
--
ALTER TABLE `lab_sop_versions`
  MODIFY `version_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `migrations`
--
ALTER TABLE `migrations`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=86;

--
-- AUTO_INCREMENT for table `modules`
--
ALTER TABLE `modules`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;

--
-- AUTO_INCREMENT for table `notifications`
--
ALTER TABLE `notifications`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;

--
-- AUTO_INCREMENT for table `otps`
--
ALTER TABLE `otps`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `permissions`
--
ALTER TABLE `permissions`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=205;

--
-- AUTO_INCREMENT for table `qms_trainings`
--
ALTER TABLE `qms_trainings`
  MODIFY `training_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `qms_training_materials`
--
ALTER TABLE `qms_training_materials`
  MODIFY `material_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `question_options`
--
ALTER TABLE `question_options`
  MODIFY `option_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `record_links`
--
ALTER TABLE `record_links`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `risk_assessments`
--
ALTER TABLE `risk_assessments`
  MODIFY `assessment_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `risk_assessment_audit_trails`
--
ALTER TABLE `risk_assessment_audit_trails`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `risk_assessment_items`
--
ALTER TABLE `risk_assessment_items`
  MODIFY `item_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `risk_assessment_links`
--
ALTER TABLE `risk_assessment_links`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `risk_assessment_templates`
--
ALTER TABLE `risk_assessment_templates`
  MODIFY `template_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `risk_assessment_template_fields`
--
ALTER TABLE `risk_assessment_template_fields`
  MODIFY `field_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `roles`
--
ALTER TABLE `roles`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=20;

--
-- AUTO_INCREMENT for table `role_curricula`
--
ALTER TABLE `role_curricula`
  MODIFY `role_curriculum_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `role_permissions`
--
ALTER TABLE `role_permissions`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=772;

--
-- AUTO_INCREMENT for table `suppliers`
--
ALTER TABLE `suppliers`
  MODIFY `supplier_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `supplier_audit_trails`
--
ALTER TABLE `supplier_audit_trails`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;

--
-- AUTO_INCREMENT for table `supplier_links`
--
ALTER TABLE `supplier_links`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `supplier_qualifications`
--
ALTER TABLE `supplier_qualifications`
  MODIFY `qualification_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `training_acknowledgements`
--
ALTER TABLE `training_acknowledgements`
  MODIFY `acknowledgement_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `training_assessments`
--
ALTER TABLE `training_assessments`
  MODIFY `assessment_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `training_assessment_answers`
--
ALTER TABLE `training_assessment_answers`
  MODIFY `answer_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `training_assessment_results`
--
ALTER TABLE `training_assessment_results`
  MODIFY `result_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `training_attendance`
--
ALTER TABLE `training_attendance`
  MODIFY `attendance_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `training_categories`
--
ALTER TABLE `training_categories`
  MODIFY `category_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `training_certificates`
--
ALTER TABLE `training_certificates`
  MODIFY `certificate_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `training_curricula`
--
ALTER TABLE `training_curricula`
  MODIFY `curriculum_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `training_effectiveness`
--
ALTER TABLE `training_effectiveness`
  MODIFY `effectiveness_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `training_escalation_log`
--
ALTER TABLE `training_escalation_log`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `training_notifications`
--
ALTER TABLE `training_notifications`
  MODIFY `notification_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `training_requirements`
--
ALTER TABLE `training_requirements`
  MODIFY `requirement_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `training_reschedule_log`
--
ALTER TABLE `training_reschedule_log`
  MODIFY `log_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `training_schedules`
--
ALTER TABLE `training_schedules`
  MODIFY `schedule_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `training_topics`
--
ALTER TABLE `training_topics`
  MODIFY `topic_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `universal_approval_actions`
--
ALTER TABLE `universal_approval_actions`
  MODIFY `action_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `universal_approval_attachments`
--
ALTER TABLE `universal_approval_attachments`
  MODIFY `attachment_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `universal_approval_delegations`
--
ALTER TABLE `universal_approval_delegations`
  MODIFY `delegation_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `universal_approval_instances`
--
ALTER TABLE `universal_approval_instances`
  MODIFY `instance_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `universal_approval_notifications`
--
ALTER TABLE `universal_approval_notifications`
  MODIFY `notification_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `universal_workflows`
--
ALTER TABLE `universal_workflows`
  MODIFY `workflow_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `universal_workflow_steps`
--
ALTER TABLE `universal_workflow_steps`
  MODIFY `step_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `user_roles`
--
ALTER TABLE `user_roles`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `workflow_step_assignees`
--
ALTER TABLE `workflow_step_assignees`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `assessment_questions`
--
ALTER TABLE `assessment_questions`
  ADD CONSTRAINT `assessment_questions_assessment_id_foreign` FOREIGN KEY (`assessment_id`) REFERENCES `training_assessments` (`assessment_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `assessment_questions_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `assessment_questions_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `assessment_questions_topic_id_foreign` FOREIGN KEY (`topic_id`) REFERENCES `training_topics` (`topic_id`) ON DELETE SET NULL,
  ADD CONSTRAINT `assessment_questions_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `audits`
--
ALTER TABLE `audits`
  ADD CONSTRAINT `audits_auditee_id_foreign` FOREIGN KEY (`auditee_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `audits_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `audits_department_id_foreign` FOREIGN KEY (`department_id`) REFERENCES `departments` (`department_id`) ON DELETE SET NULL,
  ADD CONSTRAINT `audits_lead_auditor_id_foreign` FOREIGN KEY (`lead_auditor_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `audit_audit_trails`
--
ALTER TABLE `audit_audit_trails`
  ADD CONSTRAINT `audit_audit_trails_audit_id_foreign` FOREIGN KEY (`audit_id`) REFERENCES `audits` (`audit_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `audit_audit_trails_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `audit_findings`
--
ALTER TABLE `audit_findings`
  ADD CONSTRAINT `audit_findings_audit_id_foreign` FOREIGN KEY (`audit_id`) REFERENCES `audits` (`audit_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `audit_findings_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `audit_links`
--
ALTER TABLE `audit_links`
  ADD CONSTRAINT `audit_links_audit_id_foreign` FOREIGN KEY (`audit_id`) REFERENCES `audits` (`audit_id`) ON DELETE CASCADE;

--
-- Constraints for table `capa_action_plan`
--
ALTER TABLE `capa_action_plan`
  ADD CONSTRAINT `capa_action_plan_capa_id_foreign` FOREIGN KEY (`capa_id`) REFERENCES `capa_request` (`capa_id`) ON DELETE CASCADE;

--
-- Constraints for table `capa_audit_trails`
--
ALTER TABLE `capa_audit_trails`
  ADD CONSTRAINT `capa_audit_trails_capa_id_foreign` FOREIGN KEY (`capa_id`) REFERENCES `capa_request` (`capa_id`) ON DELETE CASCADE;

--
-- Constraints for table `capa_closure`
--
ALTER TABLE `capa_closure`
  ADD CONSTRAINT `capa_closure_capa_id_foreign` FOREIGN KEY (`capa_id`) REFERENCES `capa_request` (`capa_id`) ON DELETE CASCADE;

--
-- Constraints for table `capa_documents`
--
ALTER TABLE `capa_documents`
  ADD CONSTRAINT `capa_documents_capa_id_foreign` FOREIGN KEY (`capa_id`) REFERENCES `capa_request` (`capa_id`) ON DELETE CASCADE;

--
-- Constraints for table `capa_effectiveness`
--
ALTER TABLE `capa_effectiveness`
  ADD CONSTRAINT `capa_effectiveness_capa_id_foreign` FOREIGN KEY (`capa_id`) REFERENCES `capa_request` (`capa_id`) ON DELETE CASCADE;

--
-- Constraints for table `capa_extensions`
--
ALTER TABLE `capa_extensions`
  ADD CONSTRAINT `capa_extensions_capa_id_foreign` FOREIGN KEY (`capa_id`) REFERENCES `capa_request` (`capa_id`) ON DELETE CASCADE;

--
-- Constraints for table `capa_investigations`
--
ALTER TABLE `capa_investigations`
  ADD CONSTRAINT `capa_investigations_capa_id_foreign` FOREIGN KEY (`capa_id`) REFERENCES `capa_request` (`capa_id`) ON DELETE CASCADE;

--
-- Constraints for table `change_audit_trail`
--
ALTER TABLE `change_audit_trail`
  ADD CONSTRAINT `change_audit_trail_change_id_foreign` FOREIGN KEY (`change_id`) REFERENCES `change_control_master` (`change_id`) ON DELETE CASCADE;

--
-- Constraints for table `change_control_links`
--
ALTER TABLE `change_control_links`
  ADD CONSTRAINT `change_control_links_change_id_foreign` FOREIGN KEY (`change_id`) REFERENCES `change_control_master` (`change_id`) ON DELETE CASCADE;

--
-- Constraints for table `change_effectiveness_check`
--
ALTER TABLE `change_effectiveness_check`
  ADD CONSTRAINT `change_effectiveness_check_change_id_foreign` FOREIGN KEY (`change_id`) REFERENCES `change_control_master` (`change_id`) ON DELETE CASCADE;

--
-- Constraints for table `change_impact_assessment`
--
ALTER TABLE `change_impact_assessment`
  ADD CONSTRAINT `change_impact_assessment_change_id_foreign` FOREIGN KEY (`change_id`) REFERENCES `change_control_master` (`change_id`) ON DELETE CASCADE;

--
-- Constraints for table `change_implementation_plan`
--
ALTER TABLE `change_implementation_plan`
  ADD CONSTRAINT `change_implementation_plan_change_id_foreign` FOREIGN KEY (`change_id`) REFERENCES `change_control_master` (`change_id`) ON DELETE CASCADE;

--
-- Constraints for table `complaints`
--
ALTER TABLE `complaints`
  ADD CONSTRAINT `complaints_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `complaints_department_id_foreign` FOREIGN KEY (`department_id`) REFERENCES `departments` (`department_id`) ON DELETE SET NULL,
  ADD CONSTRAINT `complaints_owner_id_foreign` FOREIGN KEY (`owner_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `complaint_audit_trails`
--
ALTER TABLE `complaint_audit_trails`
  ADD CONSTRAINT `complaint_audit_trails_complaint_id_foreign` FOREIGN KEY (`complaint_id`) REFERENCES `complaints` (`complaint_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `complaint_audit_trails_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `complaint_links`
--
ALTER TABLE `complaint_links`
  ADD CONSTRAINT `complaint_links_complaint_id_foreign` FOREIGN KEY (`complaint_id`) REFERENCES `complaints` (`complaint_id`) ON DELETE CASCADE;

--
-- Constraints for table `curriculum_topics`
--
ALTER TABLE `curriculum_topics`
  ADD CONSTRAINT `curriculum_topics_curriculum_id_foreign` FOREIGN KEY (`curriculum_id`) REFERENCES `training_curricula` (`curriculum_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `curriculum_topics_topic_id_foreign` FOREIGN KEY (`topic_id`) REFERENCES `training_topics` (`topic_id`) ON DELETE CASCADE;

--
-- Constraints for table `departments`
--
ALTER TABLE `departments`
  ADD CONSTRAINT `departments_manager_id_foreign` FOREIGN KEY (`manager_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `deviation_5whys`
--
ALTER TABLE `deviation_5whys`
  ADD CONSTRAINT `deviation_5whys_root_cause_id_foreign` FOREIGN KEY (`root_cause_id`) REFERENCES `deviation_root_causes` (`root_cause_id`) ON DELETE CASCADE;

--
-- Constraints for table `deviation_actions`
--
ALTER TABLE `deviation_actions`
  ADD CONSTRAINT `deviation_actions_assigned_to_foreign` FOREIGN KEY (`assigned_to`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `deviation_actions_deviation_id_foreign` FOREIGN KEY (`deviation_id`) REFERENCES `deviation_masters` (`deviation_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `deviation_actions_verified_by_foreign` FOREIGN KEY (`verified_by`) REFERENCES `users` (`id`);

--
-- Constraints for table `deviation_affected_items`
--
ALTER TABLE `deviation_affected_items`
  ADD CONSTRAINT `deviation_affected_items_deviation_id_foreign` FOREIGN KEY (`deviation_id`) REFERENCES `deviation_masters` (`deviation_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `deviation_affected_items_disposition_by_foreign` FOREIGN KEY (`disposition_by`) REFERENCES `users` (`id`);

--
-- Constraints for table `deviation_assessments`
--
ALTER TABLE `deviation_assessments`
  ADD CONSTRAINT `deviation_assessments_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `deviation_assessments_assessed_by_foreign` FOREIGN KEY (`assessed_by`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `deviation_assessments_deviation_id_foreign` FOREIGN KEY (`deviation_id`) REFERENCES `deviation_masters` (`deviation_id`) ON DELETE CASCADE;

--
-- Constraints for table `deviation_audit_trails`
--
ALTER TABLE `deviation_audit_trails`
  ADD CONSTRAINT `deviation_audit_trails_changed_by_foreign` FOREIGN KEY (`changed_by`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `deviation_audit_trails_deviation_id_foreign` FOREIGN KEY (`deviation_id`) REFERENCES `deviation_masters` (`deviation_id`) ON DELETE CASCADE;

--
-- Constraints for table `deviation_capa_linkages`
--
ALTER TABLE `deviation_capa_linkages`
  ADD CONSTRAINT `deviation_capa_linkages_deviation_id_foreign` FOREIGN KEY (`deviation_id`) REFERENCES `deviation_masters` (`deviation_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `deviation_capa_linkages_linked_by_foreign` FOREIGN KEY (`linked_by`) REFERENCES `users` (`id`);

--
-- Constraints for table `deviation_closures`
--
ALTER TABLE `deviation_closures`
  ADD CONSTRAINT `deviation_closures_closure_approved_by_foreign` FOREIGN KEY (`closure_approved_by`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `deviation_closures_deviation_id_foreign` FOREIGN KEY (`deviation_id`) REFERENCES `deviation_masters` (`deviation_id`) ON DELETE CASCADE;

--
-- Constraints for table `deviation_containments`
--
ALTER TABLE `deviation_containments`
  ADD CONSTRAINT `deviation_containments_deviation_id_foreign` FOREIGN KEY (`deviation_id`) REFERENCES `deviation_masters` (`deviation_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `deviation_containments_taken_by_foreign` FOREIGN KEY (`taken_by`) REFERENCES `users` (`id`);

--
-- Constraints for table `deviation_evidences`
--
ALTER TABLE `deviation_evidences`
  ADD CONSTRAINT `deviation_evidences_deviation_id_foreign` FOREIGN KEY (`deviation_id`) REFERENCES `deviation_masters` (`deviation_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `deviation_evidences_uploaded_by_foreign` FOREIGN KEY (`uploaded_by`) REFERENCES `users` (`id`);

--
-- Constraints for table `deviation_findings`
--
ALTER TABLE `deviation_findings`
  ADD CONSTRAINT `deviation_findings_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `deviation_findings_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `deviation_findings_investigation_id_foreign` FOREIGN KEY (`investigation_id`) REFERENCES `deviation_investigations` (`investigation_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `deviation_findings_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`);

--
-- Constraints for table `deviation_impacts`
--
ALTER TABLE `deviation_impacts`
  ADD CONSTRAINT `deviation_impacts_assessed_by_foreign` FOREIGN KEY (`assessed_by`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `deviation_impacts_deviation_id_foreign` FOREIGN KEY (`deviation_id`) REFERENCES `deviation_masters` (`deviation_id`) ON DELETE CASCADE;

--
-- Constraints for table `deviation_impact_items`
--
ALTER TABLE `deviation_impact_items`
  ADD CONSTRAINT `deviation_impact_items_impact_id_foreign` FOREIGN KEY (`impact_id`) REFERENCES `deviation_impacts` (`impact_id`) ON DELETE CASCADE;

--
-- Constraints for table `deviation_investigations`
--
ALTER TABLE `deviation_investigations`
  ADD CONSTRAINT `deviation_investigations_deviation_id_foreign` FOREIGN KEY (`deviation_id`) REFERENCES `deviation_masters` (`deviation_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `deviation_investigations_investigation_owner_foreign` FOREIGN KEY (`investigation_owner`) REFERENCES `users` (`id`);

--
-- Constraints for table `deviation_masters`
--
ALTER TABLE `deviation_masters`
  ADD CONSTRAINT `deviation_masters_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `deviation_masters_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `deviation_masters_department_id_foreign` FOREIGN KEY (`department_id`) REFERENCES `departments` (`department_id`),
  ADD CONSTRAINT `deviation_masters_discovered_by_foreign` FOREIGN KEY (`discovered_by`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `deviation_masters_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`);

--
-- Constraints for table `deviation_root_causes`
--
ALTER TABLE `deviation_root_causes`
  ADD CONSTRAINT `deviation_root_causes_confirmed_by_foreign` FOREIGN KEY (`confirmed_by`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `deviation_root_causes_investigation_id_foreign` FOREIGN KEY (`investigation_id`) REFERENCES `deviation_investigations` (`investigation_id`) ON DELETE CASCADE;

--
-- Constraints for table `employee_competency`
--
ALTER TABLE `employee_competency`
  ADD CONSTRAINT `employee_competency_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `employee_competency_assessed_by_foreign` FOREIGN KEY (`assessed_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `employee_competency_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `employee_competency_curriculum_id_foreign` FOREIGN KEY (`curriculum_id`) REFERENCES `training_curricula` (`curriculum_id`) ON DELETE SET NULL,
  ADD CONSTRAINT `employee_competency_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `employee_competency_employee_id_foreign` FOREIGN KEY (`employee_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `employee_competency_topic_id_foreign` FOREIGN KEY (`topic_id`) REFERENCES `training_topics` (`topic_id`) ON DELETE SET NULL,
  ADD CONSTRAINT `employee_competency_training_record_id_foreign` FOREIGN KEY (`training_record_id`) REFERENCES `qms_trainings` (`training_id`) ON DELETE SET NULL,
  ADD CONSTRAINT `employee_competency_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `employee_competency_verified_by_foreign` FOREIGN KEY (`verified_by`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `escalation_events`
--
ALTER TABLE `escalation_events`
  ADD CONSTRAINT `escalation_events_notified_user_id_foreign` FOREIGN KEY (`notified_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `escalation_events_rule_id_foreign` FOREIGN KEY (`rule_id`) REFERENCES `escalation_rules` (`rule_id`) ON DELETE CASCADE;

--
-- Constraints for table `escalation_rules`
--
ALTER TABLE `escalation_rules`
  ADD CONSTRAINT `escalation_rules_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `escalation_rules_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `escalation_rules_parent_rule_id_foreign` FOREIGN KEY (`parent_rule_id`) REFERENCES `escalation_rules` (`rule_id`) ON DELETE SET NULL;

--
-- Constraints for table `lab_sop_definitions`
--
ALTER TABLE `lab_sop_definitions`
  ADD CONSTRAINT `lab_sop_definitions_sop_id_foreign` FOREIGN KEY (`sop_id`) REFERENCES `lab_sop_documents` (`sop_id`) ON DELETE CASCADE;

--
-- Constraints for table `lab_sop_distribution`
--
ALTER TABLE `lab_sop_distribution`
  ADD CONSTRAINT `lab_sop_distribution_sop_id_foreign` FOREIGN KEY (`sop_id`) REFERENCES `lab_sop_documents` (`sop_id`) ON DELETE CASCADE;

--
-- Constraints for table `lab_sop_document_control`
--
ALTER TABLE `lab_sop_document_control`
  ADD CONSTRAINT `lab_sop_document_control_sop_id_foreign` FOREIGN KEY (`sop_id`) REFERENCES `lab_sop_documents` (`sop_id`) ON DELETE CASCADE;

--
-- Constraints for table `lab_sop_edit_history`
--
ALTER TABLE `lab_sop_edit_history`
  ADD CONSTRAINT `lab_sop_edit_history_edited_by_foreign` FOREIGN KEY (`edited_by`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `lab_sop_edit_history_sop_id_foreign` FOREIGN KEY (`sop_id`) REFERENCES `lab_sop_documents` (`sop_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `lab_sop_edit_history_version_id_foreign` FOREIGN KEY (`version_id`) REFERENCES `lab_sop_versions` (`version_id`) ON DELETE SET NULL;

--
-- Constraints for table `lab_sop_procedures`
--
ALTER TABLE `lab_sop_procedures`
  ADD CONSTRAINT `lab_sop_procedures_sop_id_foreign` FOREIGN KEY (`sop_id`) REFERENCES `lab_sop_documents` (`sop_id`) ON DELETE CASCADE;

--
-- Constraints for table `lab_sop_records_access`
--
ALTER TABLE `lab_sop_records_access`
  ADD CONSTRAINT `lab_sop_records_access_sop_id_foreign` FOREIGN KEY (`sop_id`) REFERENCES `lab_sop_documents` (`sop_id`) ON DELETE CASCADE;

--
-- Constraints for table `lab_sop_versions`
--
ALTER TABLE `lab_sop_versions`
  ADD CONSTRAINT `lab_sop_versions_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `lab_sop_versions_sop_id_foreign` FOREIGN KEY (`sop_id`) REFERENCES `lab_sop_documents` (`sop_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `lab_sop_versions_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`);

--
-- Constraints for table `qms_trainings`
--
ALTER TABLE `qms_trainings`
  ADD CONSTRAINT `qms_trainings_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `qms_trainings_current_schedule_fk` FOREIGN KEY (`current_schedule_id`) REFERENCES `training_schedules` (`schedule_id`) ON DELETE SET NULL,
  ADD CONSTRAINT `qms_trainings_curriculum_id_foreign` FOREIGN KEY (`curriculum_id`) REFERENCES `training_curricula` (`curriculum_id`) ON DELETE SET NULL,
  ADD CONSTRAINT `qms_trainings_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `qms_trainings_effectiveness_evaluated_by_foreign` FOREIGN KEY (`effectiveness_evaluated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `qms_trainings_employee_id_foreign` FOREIGN KEY (`employee_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `qms_trainings_requirement_id_foreign` FOREIGN KEY (`requirement_id`) REFERENCES `training_requirements` (`requirement_id`) ON DELETE SET NULL,
  ADD CONSTRAINT `qms_trainings_topic_id_foreign` FOREIGN KEY (`topic_id`) REFERENCES `training_topics` (`topic_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `qms_trainings_trainer_id_foreign` FOREIGN KEY (`trainer_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `qms_trainings_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `qms_training_materials`
--
ALTER TABLE `qms_training_materials`
  ADD CONSTRAINT `qms_training_materials_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `qms_training_materials_curriculum_id_foreign` FOREIGN KEY (`curriculum_id`) REFERENCES `training_curricula` (`curriculum_id`) ON DELETE SET NULL,
  ADD CONSTRAINT `qms_training_materials_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `qms_training_materials_topic_id_foreign` FOREIGN KEY (`topic_id`) REFERENCES `training_topics` (`topic_id`) ON DELETE SET NULL,
  ADD CONSTRAINT `qms_training_materials_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `question_options`
--
ALTER TABLE `question_options`
  ADD CONSTRAINT `question_options_question_id_foreign` FOREIGN KEY (`question_id`) REFERENCES `assessment_questions` (`question_id`) ON DELETE CASCADE;

--
-- Constraints for table `record_links`
--
ALTER TABLE `record_links`
  ADD CONSTRAINT `record_links_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `risk_assessments`
--
ALTER TABLE `risk_assessments`
  ADD CONSTRAINT `risk_assessments_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `risk_assessments_assessor_id_foreign` FOREIGN KEY (`assessor_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `risk_assessments_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `risk_assessments_template_id_foreign` FOREIGN KEY (`template_id`) REFERENCES `risk_assessment_templates` (`template_id`);

--
-- Constraints for table `risk_assessment_audit_trails`
--
ALTER TABLE `risk_assessment_audit_trails`
  ADD CONSTRAINT `risk_assessment_audit_trails_assessment_id_foreign` FOREIGN KEY (`assessment_id`) REFERENCES `risk_assessments` (`assessment_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `risk_assessment_audit_trails_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `risk_assessment_items`
--
ALTER TABLE `risk_assessment_items`
  ADD CONSTRAINT `risk_assessment_items_action_owner_id_foreign` FOREIGN KEY (`action_owner_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `risk_assessment_items_assessment_id_foreign` FOREIGN KEY (`assessment_id`) REFERENCES `risk_assessments` (`assessment_id`) ON DELETE CASCADE;

--
-- Constraints for table `risk_assessment_links`
--
ALTER TABLE `risk_assessment_links`
  ADD CONSTRAINT `risk_assessment_links_assessment_id_foreign` FOREIGN KEY (`assessment_id`) REFERENCES `risk_assessments` (`assessment_id`) ON DELETE CASCADE;

--
-- Constraints for table `risk_assessment_templates`
--
ALTER TABLE `risk_assessment_templates`
  ADD CONSTRAINT `risk_assessment_templates_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `risk_assessment_templates_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `risk_assessment_templates_parent_template_id_foreign` FOREIGN KEY (`parent_template_id`) REFERENCES `risk_assessment_templates` (`template_id`) ON DELETE SET NULL;

--
-- Constraints for table `risk_assessment_template_fields`
--
ALTER TABLE `risk_assessment_template_fields`
  ADD CONSTRAINT `risk_assessment_template_fields_template_id_foreign` FOREIGN KEY (`template_id`) REFERENCES `risk_assessment_templates` (`template_id`) ON DELETE CASCADE;

--
-- Constraints for table `role_curricula`
--
ALTER TABLE `role_curricula`
  ADD CONSTRAINT `role_curricula_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `role_curricula_curriculum_id_foreign` FOREIGN KEY (`curriculum_id`) REFERENCES `training_curricula` (`curriculum_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `role_curricula_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `suppliers`
--
ALTER TABLE `suppliers`
  ADD CONSTRAINT `suppliers_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `suppliers_owner_id_foreign` FOREIGN KEY (`owner_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `supplier_audit_trails`
--
ALTER TABLE `supplier_audit_trails`
  ADD CONSTRAINT `supplier_audit_trails_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `suppliers` (`supplier_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `supplier_audit_trails_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `supplier_links`
--
ALTER TABLE `supplier_links`
  ADD CONSTRAINT `supplier_links_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `suppliers` (`supplier_id`) ON DELETE CASCADE;

--
-- Constraints for table `supplier_qualifications`
--
ALTER TABLE `supplier_qualifications`
  ADD CONSTRAINT `supplier_qualifications_assessor_id_foreign` FOREIGN KEY (`assessor_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `supplier_qualifications_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `supplier_qualifications_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `suppliers` (`supplier_id`) ON DELETE CASCADE;

--
-- Constraints for table `training_acknowledgements`
--
ALTER TABLE `training_acknowledgements`
  ADD CONSTRAINT `training_acknowledgements_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_acknowledgements_employee_id_foreign` FOREIGN KEY (`employee_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `training_acknowledgements_revoked_by_foreign` FOREIGN KEY (`revoked_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_acknowledgements_training_id_foreign` FOREIGN KEY (`training_id`) REFERENCES `qms_trainings` (`training_id`) ON DELETE CASCADE;

--
-- Constraints for table `training_assessments`
--
ALTER TABLE `training_assessments`
  ADD CONSTRAINT `training_assessments_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_assessments_curriculum_id_foreign` FOREIGN KEY (`curriculum_id`) REFERENCES `training_curricula` (`curriculum_id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_assessments_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_assessments_topic_id_foreign` FOREIGN KEY (`topic_id`) REFERENCES `training_topics` (`topic_id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_assessments_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `training_assessment_answers`
--
ALTER TABLE `training_assessment_answers`
  ADD CONSTRAINT `training_assessment_answers_question_id_foreign` FOREIGN KEY (`question_id`) REFERENCES `assessment_questions` (`question_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `training_assessment_answers_result_id_foreign` FOREIGN KEY (`result_id`) REFERENCES `training_assessment_results` (`result_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `training_assessment_answers_selected_option_id_foreign` FOREIGN KEY (`selected_option_id`) REFERENCES `question_options` (`option_id`) ON DELETE SET NULL;

--
-- Constraints for table `training_assessment_results`
--
ALTER TABLE `training_assessment_results`
  ADD CONSTRAINT `training_assessment_results_assessment_id_foreign` FOREIGN KEY (`assessment_id`) REFERENCES `training_assessments` (`assessment_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `training_assessment_results_employee_id_foreign` FOREIGN KEY (`employee_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `training_assessment_results_reviewed_by_foreign` FOREIGN KEY (`reviewed_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_assessment_results_training_id_foreign` FOREIGN KEY (`training_id`) REFERENCES `qms_trainings` (`training_id`) ON DELETE CASCADE;

--
-- Constraints for table `training_attendance`
--
ALTER TABLE `training_attendance`
  ADD CONSTRAINT `training_attendance_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_attendance_employee_id_foreign` FOREIGN KEY (`employee_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `training_attendance_recorded_by_foreign` FOREIGN KEY (`recorded_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_attendance_schedule_id_foreign` FOREIGN KEY (`schedule_id`) REFERENCES `training_schedules` (`schedule_id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_attendance_training_id_foreign` FOREIGN KEY (`training_id`) REFERENCES `qms_trainings` (`training_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `training_attendance_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `training_categories`
--
ALTER TABLE `training_categories`
  ADD CONSTRAINT `training_categories_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_categories_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_categories_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `training_certificates`
--
ALTER TABLE `training_certificates`
  ADD CONSTRAINT `training_certificates_competency_id_foreign` FOREIGN KEY (`competency_id`) REFERENCES `employee_competency` (`competency_id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_certificates_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_certificates_curriculum_id_foreign` FOREIGN KEY (`curriculum_id`) REFERENCES `training_curricula` (`curriculum_id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_certificates_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_certificates_employee_id_foreign` FOREIGN KEY (`employee_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `training_certificates_issued_by_foreign` FOREIGN KEY (`issued_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_certificates_revoked_by_foreign` FOREIGN KEY (`revoked_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_certificates_topic_id_foreign` FOREIGN KEY (`topic_id`) REFERENCES `training_topics` (`topic_id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_certificates_training_id_foreign` FOREIGN KEY (`training_id`) REFERENCES `qms_trainings` (`training_id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_certificates_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `training_curricula`
--
ALTER TABLE `training_curricula`
  ADD CONSTRAINT `training_curricula_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_curricula_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_curricula_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_curricula_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `training_effectiveness`
--
ALTER TABLE `training_effectiveness`
  ADD CONSTRAINT `training_effectiveness_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_effectiveness_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_effectiveness_employee_id_foreign` FOREIGN KEY (`employee_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `training_effectiveness_monitored_by_foreign` FOREIGN KEY (`monitored_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_effectiveness_training_id_foreign` FOREIGN KEY (`training_id`) REFERENCES `qms_trainings` (`training_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `training_effectiveness_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `training_escalation_log`
--
ALTER TABLE `training_escalation_log`
  ADD CONSTRAINT `training_escalation_log_employee_id_foreign` FOREIGN KEY (`employee_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `training_escalation_log_escalated_to_foreign` FOREIGN KEY (`escalated_to`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_escalation_log_training_id_foreign` FOREIGN KEY (`training_id`) REFERENCES `qms_trainings` (`training_id`) ON DELETE CASCADE;

--
-- Constraints for table `training_notifications`
--
ALTER TABLE `training_notifications`
  ADD CONSTRAINT `training_notifications_escalated_to_user_id_foreign` FOREIGN KEY (`escalated_to_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_notifications_training_id_foreign` FOREIGN KEY (`training_id`) REFERENCES `qms_trainings` (`training_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `training_notifications_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `training_requirements`
--
ALTER TABLE `training_requirements`
  ADD CONSTRAINT `training_requirements_approved_by_foreign` FOREIGN KEY (`approved_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_requirements_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_requirements_curriculum_id_foreign` FOREIGN KEY (`curriculum_id`) REFERENCES `training_curricula` (`curriculum_id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_requirements_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_requirements_topic_id_foreign` FOREIGN KEY (`topic_id`) REFERENCES `training_topics` (`topic_id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_requirements_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `training_reschedule_log`
--
ALTER TABLE `training_reschedule_log`
  ADD CONSTRAINT `training_reschedule_log_rescheduled_by_foreign` FOREIGN KEY (`rescheduled_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_reschedule_log_schedule_id_foreign` FOREIGN KEY (`schedule_id`) REFERENCES `training_schedules` (`schedule_id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_reschedule_log_training_id_foreign` FOREIGN KEY (`training_id`) REFERENCES `qms_trainings` (`training_id`) ON DELETE CASCADE;

--
-- Constraints for table `training_schedules`
--
ALTER TABLE `training_schedules`
  ADD CONSTRAINT `training_schedules_co_trainer_id_foreign` FOREIGN KEY (`co_trainer_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_schedules_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_schedules_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_schedules_trainer_id_foreign` FOREIGN KEY (`trainer_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_schedules_training_id_foreign` FOREIGN KEY (`training_id`) REFERENCES `qms_trainings` (`training_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `training_schedules_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `training_topics`
--
ALTER TABLE `training_topics`
  ADD CONSTRAINT `training_topics_category_id_foreign` FOREIGN KEY (`category_id`) REFERENCES `training_categories` (`category_id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_topics_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_topics_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `training_topics_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `universal_approval_attachments`
--
ALTER TABLE `universal_approval_attachments`
  ADD CONSTRAINT `universal_approval_attachments_action_id_foreign` FOREIGN KEY (`action_id`) REFERENCES `universal_approval_actions` (`action_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `universal_approval_attachments_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `universal_approval_attachments_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `universal_approval_attachments_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `universal_approval_attachments_uploaded_by_foreign` FOREIGN KEY (`uploaded_by`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `universal_approval_delegations`
--
ALTER TABLE `universal_approval_delegations`
  ADD CONSTRAINT `universal_approval_delegations_cancelled_by_foreign` FOREIGN KEY (`cancelled_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `universal_approval_delegations_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `universal_approval_delegations_delegated_user_id_foreign` FOREIGN KEY (`delegated_user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `universal_approval_delegations_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `universal_approval_delegations_original_user_id_foreign` FOREIGN KEY (`original_user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `universal_approval_delegations_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `universal_approval_delegations_workflow_id_foreign` FOREIGN KEY (`workflow_id`) REFERENCES `universal_workflows` (`workflow_id`) ON DELETE SET NULL;

--
-- Constraints for table `universal_approval_notifications`
--
ALTER TABLE `universal_approval_notifications`
  ADD CONSTRAINT `universal_approval_notifications_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `universal_approval_notifications_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `universal_approval_notifications_instance_id_foreign` FOREIGN KEY (`instance_id`) REFERENCES `universal_approval_instances` (`instance_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `universal_approval_notifications_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `universal_approval_notifications_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `workflow_step_assignees`
--
ALTER TABLE `workflow_step_assignees`
  ADD CONSTRAINT `workflow_step_assignees_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `workflow_step_assignees_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `workflow_step_assignees_step_id_foreign` FOREIGN KEY (`step_id`) REFERENCES `universal_workflow_steps` (`step_id`) ON DELETE CASCADE,
  ADD CONSTRAINT `workflow_step_assignees_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
