<?php
declare(strict_types=1);

return [
    'up' => "CREATE TABLE IF NOT EXISTS `coach_academy_assignments` (
    `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    `coach_id` BIGINT UNSIGNED NOT NULL,
    `academy_id` BIGINT UNSIGNED NOT NULL,
    `level_id` BIGINT UNSIGNED NULL,
    `role` VARCHAR(30) NOT NULL DEFAULT 'coach' COMMENT 'head_coach, coach, assistant',
    `max_players` INT UNSIGNED NULL COMMENT 'Override default for this assignment',
    `assigned_from` DATE NOT NULL,
    `assigned_to` DATE NULL,
    `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,
    INDEX `idx_caa_coach` (`coach_id`),
    INDEX `idx_caa_academy` (`academy_id`),
    CONSTRAINT `fk_caa_coach` FOREIGN KEY (`coach_id`) REFERENCES `coaches`(`id`) ON DELETE CASCADE,
    CONSTRAINT `fk_caa_academy` FOREIGN KEY (`academy_id`) REFERENCES `academies`(`id`) ON DELETE CASCADE,
    CONSTRAINT `fk_caa_level` FOREIGN KEY (`level_id`) REFERENCES `academy_levels`(`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
    'down' => "DROP TABLE IF EXISTS `coach_academy_assignments`",
];
