<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE `sa_groups` (
            `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `code` VARCHAR(30) NOT NULL,
            `name_ar` VARCHAR(300) NOT NULL,
            `name_en` VARCHAR(300) NULL,
            `program_id` BIGINT UNSIGNED NOT NULL,
            `coach_id` BIGINT UNSIGNED NOT NULL,
            `min_capacity` INT UNSIGNED NOT NULL DEFAULT 1,
            `max_capacity` INT UNSIGNED NOT NULL DEFAULT 20,
            `current_count` INT UNSIGNED NOT NULL DEFAULT 0,
            `is_full` TINYINT(1) NOT NULL DEFAULT 0,
            `monthly_fee_member` DECIMAL(10,2) NOT NULL DEFAULT 0.00,
            `monthly_fee_nonmember` DECIMAL(10,2) NOT NULL DEFAULT 0.00,
            `season_start` DATE NULL,
            `season_end` DATE NULL,
            `status` VARCHAR(20) NOT NULL DEFAULT 'active' COMMENT 'active, paused, completed, cancelled',
            `is_archived` TINYINT(1) NOT NULL DEFAULT 0,
            `archived_at` TIMESTAMP NULL,
            `archived_by` BIGINT UNSIGNED 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_sa_grp_code` (`code`),
            INDEX `idx_sa_grp_program` (`program_id`),
            INDEX `idx_sa_grp_coach` (`coach_id`),
            INDEX `idx_sa_grp_status` (`status`),
            CONSTRAINT `fk_sa_grp_program` FOREIGN KEY (`program_id`) REFERENCES `sa_programs`(`id`) ON DELETE RESTRICT,
            CONSTRAINT `fk_sa_grp_coach` FOREIGN KEY (`coach_id`) REFERENCES `sa_coaches`(`id`) ON DELETE RESTRICT
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `sa_groups`",
];
