<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `hr_performance_cycles` (
            `id`                    BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `cycle_code`            VARCHAR(30) NOT NULL,
            `name_ar`               VARCHAR(200) NOT NULL,
            `name_en`               VARCHAR(200) NULL,
            `year`                  YEAR NOT NULL,
            `period_type`           VARCHAR(20) NOT NULL DEFAULT 'annual' COMMENT 'annual, semi_annual, quarterly',
            `start_date`            DATE NOT NULL,
            `end_date`              DATE NOT NULL,
            `review_deadline`       DATE NOT NULL,
            `status`                VARCHAR(20) NOT NULL DEFAULT 'draft' COMMENT 'draft, active, review, closed',
            `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_perf_cycle_code` (`cycle_code`),
            INDEX `idx_hr_perf_cycle_year` (`year`),
            INDEX `idx_hr_perf_cycle_status` (`status`),
            CONSTRAINT `chk_hr_perf_cycle_type` CHECK (`period_type` IN ('annual', 'semi_annual', 'quarterly')),
            CONSTRAINT `chk_hr_perf_cycle_status` CHECK (`status` IN ('draft', 'active', 'review', 'closed'))
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `hr_performance_cycles`",
];
