UPDATE payments_ledger AS ledger
SET date = payment.renewal_date,
    updated_at = NOW()
FROM subscription_payments AS payment
WHERE ledger.source_type = 'subscription'
  AND ledger.source_id = payment.id
  AND ledger.date IS DISTINCT FROM payment.renewal_date;
