<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `hr_work_schedules` (
            `id`                    BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `code`                  VARCHAR(30) NOT NULL,
            `name_ar`               VARCHAR(200) NOT NULL,
            `name_en`               VARCHAR(200) NULL,
            `schedule_type`         VARCHAR(20) NOT NULL DEFAULT 'fixed' COMMENT 'fixed, rotating, flexible',
            `working_days_per_week` INT UNSIGNED NOT NULL DEFAULT 6,
            `hours_per_day`         DECIMAL(4,2) NOT NULL DEFAULT 8.00,
            `hours_per_week`        DECIMAL(5,2) NOT NULL DEFAULT 48.00,
            `ramadan_hours_per_day` DECIMAL(4,2) NOT NULL DEFAULT 7.00,
            `is_night_shift`        TINYINT(1) NOT NULL DEFAULT 0,
            `start_time`            TIME NULL,
            `end_time`              TIME NULL,
            `break_duration_minutes` INT UNSIGNED NOT NULL DEFAULT 60,
            `late_tolerance_minutes` INT UNSIGNED NOT NULL DEFAULT 15,
            `early_leave_tolerance` INT UNSIGNED NOT NULL DEFAULT 15,
            `days_config_json`      JSON NOT NULL,
            `is_default`            TINYINT(1) NOT NULL DEFAULT 0,
            `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,
            `is_archived`           TINYINT(1) NOT NULL DEFAULT 0,
            `archived_at`           TIMESTAMP NULL DEFAULT NULL,
            `archived_by`           BIGINT UNSIGNED NULL,
            UNIQUE KEY `uq_hr_work_schedules_code` (`code`),
            INDEX `idx_hr_work_schedules_active` (`is_active`),
            CONSTRAINT `chk_hr_work_sched_type` CHECK (`schedule_type` IN ('fixed', 'rotating', 'flexible'))
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `hr_work_schedules`",
];
