<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE `sa_group_players` (
            `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `group_id` BIGINT UNSIGNED NOT NULL,
            `player_id` BIGINT UNSIGNED NOT NULL,
            `enrolled_at` DATE NOT NULL,
            `left_at` DATE NULL,
            `status` VARCHAR(20) NOT NULL DEFAULT 'active' COMMENT 'active, paused, transferred, withdrawn',
            `notes` TEXT 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_sa_gp_group` (`group_id`),
            INDEX `idx_sa_gp_player` (`player_id`),
            INDEX `idx_sa_gp_status` (`status`),
            CONSTRAINT `fk_sa_gp_group` FOREIGN KEY (`group_id`) REFERENCES `sa_groups`(`id`) ON DELETE CASCADE,
            CONSTRAINT `fk_sa_gp_player` FOREIGN KEY (`player_id`) REFERENCES `sa_players`(`id`) ON DELETE CASCADE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `sa_group_players`",
];
