
ALTER TABLE listing_claims
  ADD COLUMN verification_token VARCHAR(64) DEFAULT NULL AFTER message,
  ADD COLUMN verification_expires_at DATETIME DEFAULT NULL AFTER verification_token,
  ADD COLUMN email_verified_at TIMESTAMP NULL DEFAULT NULL AFTER verification_expires_at,
  ADD COLUMN claimed_email VARCHAR(255) DEFAULT NULL AFTER email_verified_at,
  ADD UNIQUE KEY idx_claim_verify_token (verification_token);

ALTER TABLE listing_claims
  MODIFY COLUMN status ENUM('pending_email','pending','approved','rejected') NOT NULL DEFAULT 'pending_email';

UPDATE listing_claims
SET email_verified_at = COALESCE(email_verified_at, created_at)
WHERE status = 'pending' AND email_verified_at IS NULL;
