<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `hr_salary_adjustments` (
            `id`                    BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `employee_id`           BIGINT UNSIGNED NOT NULL,
            `adjustment_type`       VARCHAR(30) NOT NULL COMMENT 'raise, promotion, demotion, annual_increment, correction',
            `previous_basic_salary` DECIMAL(15,2) NOT NULL,
            `new_basic_salary`      DECIMAL(15,2) NOT NULL,
            `previous_job_title_id` BIGINT UNSIGNED NULL,
            `new_job_title_id`      BIGINT UNSIGNED NULL,
            `effective_date`        DATE NOT NULL,
            `reason`                TEXT NULL,
            `approved_by`           BIGINT UNSIGNED NULL,
            `approved_at`           TIMESTAMP NULL DEFAULT NULL,
            `status`                VARCHAR(20) NOT NULL DEFAULT 'pending' COMMENT 'pending, approved, applied, rejected',
            `notes`                 TEXT 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,
            INDEX `idx_hr_adj_employee` (`employee_id`),
            INDEX `idx_hr_adj_effective` (`effective_date`),
            INDEX `idx_hr_adj_status` (`status`),
            INDEX `idx_hr_adj_type` (`adjustment_type`),
            CONSTRAINT `fk_hr_adj_employee` FOREIGN KEY (`employee_id`) REFERENCES `employees`(`id`),
            CONSTRAINT `chk_hr_adj_type` CHECK (`adjustment_type` IN ('raise', 'promotion', 'demotion', 'annual_increment', 'correction')),
            CONSTRAINT `chk_hr_adj_status` CHECK (`status` IN ('pending', 'approved', 'applied', 'rejected')),
            CONSTRAINT `chk_hr_adj_salary` CHECK (`new_basic_salary` >= 0)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `hr_salary_adjustments`",
];
