-
Notifications
You must be signed in to change notification settings - Fork 0
PM-1206 - reset payment status #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
-- Update all payments witha "owed" status to "on_hold" for users that don't have a trolley_id | ||
-- and no trolley_recipient_payment_method set. | ||
|
||
UPDATE payment | ||
SET payment_status = 'ON_HOLD' | ||
WHERE winnings_id IN ( | ||
SELECT winnings.winning_id | ||
FROM winnings | ||
LEFT JOIN trolley_recipient ON winnings.winner_id = trolley_recipient.user_id | ||
LEFT JOIN trolley_recipient_payment_method ON trolley_recipient.id = trolley_recipient_payment_method.trolley_recipient_id | ||
WHERE payment.payment_status = 'OWED' AND ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. high |
||
trolley_recipient.trolley_id IS NULL OR | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we please remove this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is cleared in Slack. |
||
trolley_recipient_payment_method.id IS NULL | ||
) | ||
); | ||
|
||
-- To test & see the updated payments: | ||
-- | ||
-- SELECT payment.payment_id, | ||
-- payment.total_amount, | ||
-- payment.installment_number, | ||
-- payment.payment_method_id, | ||
-- payment.version, | ||
-- payment.payment_status, | ||
-- winnings.winner_id, | ||
-- trolley_recipient.trolley_id, | ||
-- trolley_recipient_payment_method.recipient_account_id | ||
-- FROM payment | ||
-- LEFT JOIN winnings ON payment.winnings_id = winnings.winning_id | ||
-- LEFT JOIN trolley_recipient ON winnings.winner_id = trolley_recipient.user_id | ||
-- LEFT JOIN trolley_recipient_payment_method ON trolley_recipient.id = trolley_recipient_payment_method.trolley_recipient_id | ||
-- WHERE payment.payment_status = 'OWED' | ||
-- AND trolley_recipient.trolley_id IS NULL | ||
-- AND trolley_recipient_payment_method.id IS NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
medium
performance
The subquery in the
WHERE
clause could potentially lead to performance issues if thewinnings
table is large. Consider using anEXISTS
clause instead ofIN
to improve performance by stopping at the first match.