<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE `sa_programs` (
            `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `code` VARCHAR(30) NOT NULL,
            `name_ar` VARCHAR(300) NOT NULL,
            `name_en` VARCHAR(300) NULL,
            `discipline_id` BIGINT UNSIGNED NOT NULL,
            `academy_id` BIGINT UNSIGNED NULL,
            `program_type` VARCHAR(30) NOT NULL DEFAULT 'training' COMMENT 'training, recreational, competitive, rehabilitation',
            `age_from` INT UNSIGNED NULL,
            `age_to` INT UNSIGNED NULL,
            `gender_restriction` VARCHAR(10) NULL COMMENT 'male, female, NULL=mixed',
            `skill_level` VARCHAR(30) NULL COMMENT 'beginner, intermediate, advanced, elite',
            `description_ar` TEXT NULL,
            `session_duration_minutes` INT UNSIGNED NOT NULL DEFAULT 60,
            `sessions_per_week` INT UNSIGNED NOT NULL DEFAULT 3,
            `is_active` TINYINT(1) NOT NULL DEFAULT 1,
            `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_prog_code` (`code`),
            INDEX `idx_sa_prog_disc` (`discipline_id`),
            INDEX `idx_sa_prog_academy` (`academy_id`),
            INDEX `idx_sa_prog_active` (`is_active`, `is_archived`),
            CONSTRAINT `fk_sa_prog_disc` FOREIGN KEY (`discipline_id`) REFERENCES `sa_disciplines`(`id`) ON DELETE RESTRICT,
            CONSTRAINT `fk_sa_prog_academy` FOREIGN KEY (`academy_id`) REFERENCES `sa_academies`(`id`) ON DELETE SET NULL
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `sa_programs`",
];
