<?php
declare(strict_types=1);
return [
    'up' => "CREATE TABLE IF NOT EXISTS `academy_enrollments` (
    `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    `player_id` BIGINT UNSIGNED NOT NULL,
    `academy_id` BIGINT UNSIGNED NOT NULL,
    `level_id` BIGINT UNSIGNED NULL,
    `schedule_id` BIGINT UNSIGNED NULL,
    `season` VARCHAR(20) NULL,
    `enrolled_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `enrollment_day` TINYINT UNSIGNED NULL COMMENT 'Day of month when enrolled (for half-month logic)',
    `status` VARCHAR(20) NOT NULL DEFAULT 'active' COMMENT 'active, suspended, dropped, promoted, completed',
    `promoted_from_id` BIGINT UNSIGNED NULL COMMENT 'Previous enrollment ID if promoted',
    `dropped_at` TIMESTAMP NULL DEFAULT NULL,
    `dropped_reason` VARCHAR(500) 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,
    INDEX `idx_ae_player` (`player_id`),
    INDEX `idx_ae_academy` (`academy_id`),
    INDEX `idx_ae_level` (`level_id`),
    INDEX `idx_ae_status` (`status`),
    INDEX `idx_ae_season` (`season`),
    CONSTRAINT `fk_ae_player` FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE,
    CONSTRAINT `fk_ae_academy` FOREIGN KEY (`academy_id`) REFERENCES `academies`(`id`) ON DELETE RESTRICT,
    CONSTRAINT `fk_ae_level` FOREIGN KEY (`level_id`) REFERENCES `academy_levels`(`id`) ON DELETE SET NULL,
    CONSTRAINT `fk_ae_schedule` FOREIGN KEY (`schedule_id`) REFERENCES `academy_schedules`(`id`) ON DELETE SET NULL,
    CONSTRAINT `fk_ae_promoted_from` FOREIGN KEY (`promoted_from_id`) REFERENCES `academy_enrollments`(`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
    'down' => "DROP TABLE IF EXISTS `academy_enrollments`",
];
