mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 14:48:18 +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;
|
||||
`);
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ export class PaymentEntity extends BaseEntity {
|
||||
@Column({ type: "enum", enum: ["action-required", "processing", "success", "failed", "canceled", "refunded"], default: "action-required" })
|
||||
status!: PaymentStatus
|
||||
|
||||
@Column({ type: "date", nullable: true, name: "paid_at" })
|
||||
@Column({ type: "timestamp", nullable: true, name: "paid_at" })
|
||||
paidAt?: Date
|
||||
|
||||
@Column({ type: "timestamp", nullable: true, name: "refunded_at" })
|
||||
|
||||
Reference in New Issue
Block a user