<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `hr_leave_types` (
            `id`                    BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `code`                  VARCHAR(30) NOT NULL,
            `name_ar`               VARCHAR(200) NOT NULL,
            `name_en`               VARCHAR(200) NULL,
            `category`              VARCHAR(30) NULL COMMENT 'annual, sick, special, casual, unpaid',
            `default_days_per_year` DECIMAL(5,1) NULL,
            `max_days_per_year`     DECIMAL(5,1) NULL,
            `is_paid`               TINYINT(1) NOT NULL DEFAULT 1,
            `pay_percentage`        DECIMAL(5,2) NOT NULL DEFAULT 100.00,
            `requires_approval`     TINYINT(1) NOT NULL DEFAULT 1,
            `requires_attachment`   TINYINT(1) NOT NULL DEFAULT 0,
            `min_days_per_request`  DECIMAL(5,1) NULL,
            `max_days_per_request`  DECIMAL(5,1) NULL,
            `min_consecutive_annual` DECIMAL(5,1) NULL,
            `max_consecutive_days`  INT UNSIGNED NULL,
            `max_per_occurrence`    INT UNSIGNED NULL,
            `max_times_in_career`   INT UNSIGNED NULL,
            `min_service_months`    INT UNSIGNED NULL,
            `advance_notice_days`   INT UNSIGNED NOT NULL DEFAULT 0,
            `gender_restriction`    VARCHAR(10) NULL DEFAULT NULL COMMENT 'male, female, null=all',
            `carry_over_allowed`    TINYINT(1) NOT NULL DEFAULT 0,
            `max_carry_over_days`   DECIMAL(5,1) NULL,
            `carry_over_expiry_months` INT UNSIGNED NULL,
            `is_accumulative`       TINYINT(1) NOT NULL DEFAULT 0,
            `accumulation_max_years` INT UNSIGNED NULL DEFAULT 3,
            `career_max_times`      INT UNSIGNED NULL,
            `career_max_days`       DECIMAL(5,1) NULL,
            `deduct_from_salary`    TINYINT(1) NOT NULL DEFAULT 0,
            `legal_reference`       VARCHAR(100) NULL,
            `rules_json`            JSON NULL,
            `is_active`             TINYINT(1) NOT NULL DEFAULT 1,
            `sort_order`            INT UNSIGNED NOT NULL DEFAULT 0,
            `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_leave_types_code` (`code`),
            INDEX `idx_hr_leave_types_active` (`is_active`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `hr_leave_types`",
];
