<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `hr_employee_profiles` (
            `id`                    BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `employee_id`           BIGINT UNSIGNED NOT NULL,
            `employee_number`       VARCHAR(20) NOT NULL,
            `first_name_ar`         VARCHAR(100) NOT NULL,
            `last_name_ar`          VARCHAR(100) NOT NULL,
            `first_name_en`         VARCHAR(100) NULL,
            `last_name_en`          VARCHAR(100) NULL,
            `phone`                 VARCHAR(20) NULL,
            `email`                 VARCHAR(200) NULL,
            `national_id`           VARCHAR(14) NULL,
            `date_of_birth`         DATE NULL,
            `gender`                VARCHAR(10) NULL COMMENT 'male, female',
            `marital_status`        VARCHAR(20) NULL COMMENT 'single, married, divorced, widowed',
            `religion`              VARCHAR(20) NULL COMMENT 'muslim, christian, other',
            `nationality`           VARCHAR(50) NOT NULL DEFAULT 'egyptian',
            `address`               TEXT NULL,
            `emergency_contact_name`  VARCHAR(200) NULL,
            `emergency_contact_phone` VARCHAR(20) NULL,
            `department_id`         BIGINT UNSIGNED NULL,
            `job_title_id`          BIGINT UNSIGNED NULL,
            `direct_manager_id`     BIGINT UNSIGNED NULL,
            `hire_date`             DATE NOT NULL,
            `probation_end_date`    DATE NULL,
            `probation_status`      VARCHAR(20) NULL DEFAULT 'in_probation' COMMENT 'in_probation, passed, failed',
            `employment_type`       VARCHAR(20) NOT NULL DEFAULT 'full_time' COMMENT 'full_time, part_time, contract, temporary',
            `employment_status`     VARCHAR(20) NOT NULL DEFAULT 'active' COMMENT 'active, probation, on_leave, suspended, terminated, resigned',
            `salary_structure_id`   BIGINT UNSIGNED NULL,
            `basic_salary`          DECIMAL(15,2) NOT NULL DEFAULT 0.00,
            `insurable_salary`      DECIMAL(15,2) NOT NULL DEFAULT 0.00,
            `bank_name`             VARCHAR(200) NULL,
            `bank_account_number`   VARCHAR(50) NULL,
            `bank_iban`             VARCHAR(34) NULL,
            `insurance_number`      VARCHAR(20) NULL,
            `insurance_start_date`  DATE NULL,
            `tax_card_number`       VARCHAR(20) NULL,
            `military_status`       VARCHAR(20) NULL COMMENT 'exempted, completed, postponed, not_applicable',
            `has_disability`        TINYINT(1) NOT NULL DEFAULT 0,
            `disability_details`    TEXT NULL,
            `notes`                 TEXT NULL,
            `photo_path`            VARCHAR(500) NULL,
            `termination_date`      DATE NULL,
            `termination_type`      VARCHAR(30) NULL,
            `termination_reason`    TEXT NULL,
            `last_working_day`      DATE NULL,
            `created_at`            TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
            `updated_at`            TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
            `created_by`            BIGINT UNSIGNED NULL,
            `updated_by`            BIGINT UNSIGNED NULL,
            `is_archived`           TINYINT(1) NOT NULL DEFAULT 0,
            `archived_at`           TIMESTAMP NULL DEFAULT NULL,
            `archived_by`           BIGINT UNSIGNED NULL,
            UNIQUE KEY `uq_hr_profiles_employee` (`employee_id`),
            UNIQUE KEY `uq_hr_profiles_number` (`employee_number`),
            INDEX `idx_hr_profiles_national_id` (`national_id`),
            INDEX `idx_hr_profiles_department` (`department_id`),
            INDEX `idx_hr_profiles_job_title` (`job_title_id`),
            INDEX `idx_hr_profiles_manager` (`direct_manager_id`),
            INDEX `idx_hr_profiles_status` (`employment_status`),
            INDEX `idx_hr_profiles_hire_date` (`hire_date`),
            INDEX `idx_hr_profiles_insurance` (`insurance_number`),
            INDEX `idx_hr_profiles_archived` (`is_archived`),
            CONSTRAINT `fk_hr_profiles_employee` FOREIGN KEY (`employee_id`) REFERENCES `employees`(`id`),
            CONSTRAINT `fk_hr_profiles_department` FOREIGN KEY (`department_id`) REFERENCES `hr_departments`(`id`) ON DELETE SET NULL,
            CONSTRAINT `fk_hr_profiles_job_title` FOREIGN KEY (`job_title_id`) REFERENCES `hr_job_titles`(`id`) ON DELETE SET NULL,
            CONSTRAINT `fk_hr_profiles_manager` FOREIGN KEY (`direct_manager_id`) REFERENCES `employees`(`id`) ON DELETE SET NULL,
            CONSTRAINT `fk_hr_profiles_salary_structure` FOREIGN KEY (`salary_structure_id`) REFERENCES `hr_salary_structures`(`id`) ON DELETE SET NULL,
            CONSTRAINT `chk_hr_profiles_gender` CHECK (`gender` IN ('male', 'female')),
            CONSTRAINT `chk_hr_profiles_marital` CHECK (`marital_status` IN ('single', 'married', 'divorced', 'widowed')),
            CONSTRAINT `chk_hr_profiles_religion` CHECK (`religion` IN ('muslim', 'christian', 'other')),
            CONSTRAINT `chk_hr_profiles_emp_type` CHECK (`employment_type` IN ('full_time', 'part_time', 'contract', 'temporary')),
            CONSTRAINT `chk_hr_profiles_basic_salary` CHECK (`basic_salary` >= 0)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `hr_employee_profiles`",
];
