<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `hr_employee_salary_details` (
            `id`                    BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `employee_profile_id`   BIGINT UNSIGNED NOT NULL,
            `component_id`          BIGINT UNSIGNED NOT NULL,
            `amount`                DECIMAL(15,2) NOT NULL DEFAULT 0.00,
            `percentage`            DECIMAL(5,2) NULL,
            `effective_from`        DATE NOT NULL,
            `effective_to`          DATE NULL,
            `is_active`             TINYINT(1) NOT NULL DEFAULT 1,
            `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,
            INDEX `idx_hr_emp_salary_employee` (`employee_profile_id`),
            INDEX `idx_hr_emp_salary_component` (`component_id`),
            INDEX `idx_hr_emp_salary_effective` (`effective_from`, `effective_to`),
            INDEX `idx_hr_emp_salary_active` (`is_active`),
            CONSTRAINT `fk_hr_emp_salary_employee` FOREIGN KEY (`employee_profile_id`) REFERENCES `hr_employee_profiles`(`id`),
            CONSTRAINT `fk_hr_emp_salary_component` FOREIGN KEY (`component_id`) REFERENCES `hr_salary_components`(`id`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `hr_employee_salary_details`",
];
