mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 04:15:43 +00:00
fix:cbe and cac
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
/**
|
||||
* `freight.payments.paid_at` was created as `date` (CreatePaymentTable) and never
|
||||
* migrated to `timestamp` alongside its siblings `refunded_at`/`expires_at`
|
||||
* (UpdatePaymentTimestamp). TypeORM's postgres driver hydrates `date` columns as a
|
||||
* plain "YYYY-MM-DD" string, not a `Date` — so `PaymentEntity.paidAt` (typed `Date`)
|
||||
* was actually a string once read back from the DB, and
|
||||
* `intent.paidAt?.toISOString()` in PaymentService.formatIntentStatus threw
|
||||
* `TypeError: intent.paidAt.toISOString is not a function`. This hit every
|
||||
* OTP-confirm response (CAC Bank) because confirmOtp always re-reads the intent
|
||||
* before formatting the response.
|
||||
*/
|
||||
export class FixPaymentPaidAtType3160000000000 implements MigrationInterface {
|
||||
name = "FixPaymentPaidAtType3160000000000";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE freight.payments
|
||||
ALTER COLUMN paid_at TYPE timestamp
|
||||
USING paid_at::timestamp;
|
||||
`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE freight.payments
|
||||
ALTER COLUMN paid_at TYPE date
|
||||
USING paid_at::date;
|
||||
`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user