-- Migration 081: Status superseded wenn freigegebener Verein gelöscht wurde

ALTER TABLE club_creation_requests
    DROP CONSTRAINT IF EXISTS club_creation_requests_status_check;

ALTER TABLE club_creation_requests
    ADD CONSTRAINT club_creation_requests_status_check
    CHECK (status IN ('pending', 'approved', 'rejected', 'withdrawn', 'superseded'));

-- Bestehende Drift: approved ohne Verein (ON DELETE SET NULL auf created_club_id)
UPDATE club_creation_requests
SET status = 'superseded', updated_at = NOW()
WHERE status = 'approved' AND created_club_id IS NULL;
