Skip to content

Commit 86c1b99

Browse files
authored
Merge pull request #59 from topcoder-platform/PM-1206_reset-payment-status
PM-1206 - reset payment status
2 parents 7ad1504 + e95b40f commit 86c1b99

File tree

1 file changed

+34
-0
lines changed
  • prisma/migrations/20250520061120_reset_payments_status

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
-- Update all payments witha "owed" status to "on_hold" for users that don't have a trolley_id
2+
-- and no trolley_recipient_payment_method set.
3+
4+
UPDATE payment
5+
SET payment_status = 'ON_HOLD'
6+
WHERE winnings_id IN (
7+
SELECT winnings.winning_id
8+
FROM winnings
9+
LEFT JOIN trolley_recipient ON winnings.winner_id = trolley_recipient.user_id
10+
LEFT JOIN trolley_recipient_payment_method ON trolley_recipient.id = trolley_recipient_payment_method.trolley_recipient_id
11+
WHERE payment.payment_status = 'OWED' AND (
12+
trolley_recipient.trolley_id IS NULL OR
13+
trolley_recipient_payment_method.id IS NULL
14+
)
15+
);
16+
17+
-- To test & see the updated payments:
18+
--
19+
-- SELECT payment.payment_id,
20+
-- payment.total_amount,
21+
-- payment.installment_number,
22+
-- payment.payment_method_id,
23+
-- payment.version,
24+
-- payment.payment_status,
25+
-- winnings.winner_id,
26+
-- trolley_recipient.trolley_id,
27+
-- trolley_recipient_payment_method.recipient_account_id
28+
-- FROM payment
29+
-- LEFT JOIN winnings ON payment.winnings_id = winnings.winning_id
30+
-- LEFT JOIN trolley_recipient ON winnings.winner_id = trolley_recipient.user_id
31+
-- LEFT JOIN trolley_recipient_payment_method ON trolley_recipient.id = trolley_recipient_payment_method.trolley_recipient_id
32+
-- WHERE payment.payment_status = 'OWED'
33+
-- AND trolley_recipient.trolley_id IS NULL
34+
-- AND trolley_recipient_payment_method.id IS NULL;

0 commit comments

Comments
 (0)