<?php
declare(strict_types=1);

return [
    'up' => "CREATE TABLE IF NOT EXISTS `group_memberships` (
    `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    `group_id` BIGINT UNSIGNED NOT NULL,
    `enrollment_id` BIGINT UNSIGNED NOT NULL,
    `player_id` BIGINT UNSIGNED NOT NULL,
    `joined_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `left_at` TIMESTAMP NULL,
    `status` VARCHAR(20) NOT NULL DEFAULT 'active' COMMENT 'active, transferred, removed',
    `transferred_to_group_id` BIGINT UNSIGNED NULL,
    `transfer_reason` VARCHAR(500) NULL,
    `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    INDEX `idx_gm_group` (`group_id`),
    INDEX `idx_gm_player` (`player_id`),
    CONSTRAINT `fk_gm_group` FOREIGN KEY (`group_id`) REFERENCES `training_groups`(`id`) ON DELETE CASCADE,
    CONSTRAINT `fk_gm_enrollment` FOREIGN KEY (`enrollment_id`) REFERENCES `academy_enrollments`(`id`) ON DELETE CASCADE,
    CONSTRAINT `fk_gm_player` FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
    'down' => "DROP TABLE IF EXISTS `group_memberships`",
];
