<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `hr_leave_balances` (
            `id`                    BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `employee_profile_id`   BIGINT UNSIGNED NOT NULL,
            `leave_type_id`         BIGINT UNSIGNED NOT NULL,
            `year`                  YEAR NOT NULL,
            `entitled_days`         DECIMAL(5,1) NOT NULL DEFAULT 0.0,
            `carried_over_days`     DECIMAL(5,1) NOT NULL DEFAULT 0.0,
            `used_days`             DECIMAL(5,1) NOT NULL DEFAULT 0.0,
            `pending_days`          DECIMAL(5,1) NOT NULL DEFAULT 0.0,
            `adjustment_days`       DECIMAL(5,1) NOT NULL DEFAULT 0.0,
            `adjustment_reason`     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,
            UNIQUE KEY `uq_hr_leave_bal` (`employee_profile_id`, `leave_type_id`, `year`),
            INDEX `idx_hr_leave_bal_employee` (`employee_profile_id`),
            INDEX `idx_hr_leave_bal_year` (`year`),
            INDEX `idx_hr_leave_bal_type` (`leave_type_id`),
            CONSTRAINT `fk_hr_leave_bal_employee` FOREIGN KEY (`employee_profile_id`) REFERENCES `hr_employee_profiles`(`id`),
            CONSTRAINT `fk_hr_leave_bal_type` FOREIGN KEY (`leave_type_id`) REFERENCES `hr_leave_types`(`id`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `hr_leave_balances`",
];
