<?php
declare(strict_types=1);

return [
    'up' => "
ALTER TABLE player_medical_records
    DROP FOREIGN KEY fk_pmr_player;
ALTER TABLE player_medical_records
    MODIFY player_id BIGINT UNSIGNED NULL,
    ADD COLUMN sa_player_id INT UNSIGNED NULL AFTER player_id,
    ADD COLUMN sa_document_id INT UNSIGNED NULL AFTER document_id,
    ADD COLUMN source VARCHAR(30) NOT NULL DEFAULT 'membership' AFTER approval_status,
    ADD INDEX idx_pmr_sa_player (sa_player_id),
    ADD INDEX idx_pmr_source (source)
",
    'down' => "
ALTER TABLE player_medical_records
    DROP INDEX idx_pmr_source,
    DROP INDEX idx_pmr_sa_player,
    DROP COLUMN source,
    DROP COLUMN sa_document_id,
    DROP COLUMN sa_player_id,
    MODIFY player_id BIGINT UNSIGNED NOT NULL;
ALTER TABLE player_medical_records
    ADD CONSTRAINT fk_pmr_player FOREIGN KEY (player_id) REFERENCES players(id) ON DELETE CASCADE
",
];
