-- Rollback for v1.0.6.2 void-unpaid cleanup.
-- Restores the previous status for every row recorded in the audit table,
-- then drops the audit table itself.

UPDATE user_subscriptions us
   SET status = vs.previous_status,
       canceled_at = NULL,
       updated_at = NOW()
  FROM voided_subscriptions_20260417 vs
 WHERE us.id = vs.subscription_id
   AND us.status = 'expired';

DROP TABLE IF EXISTS voided_subscriptions_20260417;
