<?php
declare(strict_types=1);

return function (\App\Core\Database $db): void {
    $db->raw("ALTER TABLE carnet_guest_entries DROP FOREIGN KEY fk_cge_carnet");
    $db->raw("ALTER TABLE carnet_guest_entries DROP FOREIGN KEY fk_cge_member");

    $db->raw("ALTER TABLE carnet_guest_entries MODIFY carnet_id BIGINT UNSIGNED NULL DEFAULT NULL");
    $db->raw("ALTER TABLE carnet_guest_entries MODIFY member_id BIGINT UNSIGNED NULL DEFAULT NULL");

    $db->raw("ALTER TABLE carnet_guest_entries ADD CONSTRAINT fk_cge_carnet FOREIGN KEY (carnet_id) REFERENCES carnets(id) ON DELETE SET NULL");
    $db->raw("ALTER TABLE carnet_guest_entries ADD CONSTRAINT fk_cge_member FOREIGN KEY (member_id) REFERENCES members(id) ON DELETE SET NULL");
};
