-- Claim links can now be created without a campaign -- products carry the
-- keys, and admins claim links per product; campaigns are for grouping
-- keys/links for analytics/reporting, not a requirement of the core flow.
-- default_max_claims was already write-only past the point campaign_id is
-- null (ClaimLinkFactory::resolveMaxClaims() already tolerates a null
-- campaign tier, falling through to the product default), so nothing else
-- needs backfilling here.
--
-- The FK also switches from ON DELETE CASCADE to ON DELETE SET NULL
-- (matching creator_group_id's existing behavior on this same table):
-- deleting a campaign detaches its claim links instead of deleting them
-- and their redemption history along with it.

ALTER TABLE claim_links DROP FOREIGN KEY fk_link_campaign;
ALTER TABLE claim_links MODIFY campaign_id INT UNSIGNED NULL;
ALTER TABLE claim_links ADD CONSTRAINT fk_link_campaign FOREIGN KEY (campaign_id) REFERENCES campaigns(id) ON DELETE SET NULL;
