fix:cbe and cac

This commit is contained in:
Nathnael
2026-08-02 20:37:16 +00:00
parent da1da7befb
commit 6f137a11c3
4 changed files with 65 additions and 7 deletions

View File

@@ -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;
`);
}
}