-
-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Stripe): set expiry date for payment intent cards
- Loading branch information
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
migrations/20241212132217-set-expiry-date-stripe-payment-intents.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
async up(queryInterface) { | ||
await queryInterface.sequelize.query(` | ||
UPDATE "PaymentMethods" | ||
SET | ||
"expiryDate" = to_date((data ->> 'expYear')::varchar || '-' || (data ->> 'expMonth')::varchar, 'YYYY-MM') + INTERVAL '1 month' - INTERVAL '1 ms', | ||
"data" = JSONB_SET(data, '{expiryDateSetFrom20241212132217Migration}', 'true'::jsonb) | ||
WHERE "expiryDate" IS NULL | ||
AND data ->> 'expYear' IS NOT NULL | ||
AND data ->> 'expMonth' IS NOT NULL | ||
AND "deletedAt" IS NULL | ||
`); | ||
}, | ||
|
||
async down(queryInterface) { | ||
await queryInterface.sequelize.query(` | ||
UPDATE "PaymentMethods" | ||
SET | ||
"expiryDate" = NULL, | ||
"data" = data - 'expiryDateSetFrom20241212132217Migration' | ||
WHERE data -> 'expiryDateSetFrom20241212132217Migration' IS NOT NULL | ||
AND "deletedAt" IS NULL | ||
`); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters