fix: ( payment ) change the amount to number

This commit is contained in:
Abubeker Yasin
2026-06-20 09:27:46 +03:00
parent 2288a9efda
commit 77ab3cf632
3 changed files with 39 additions and 6 deletions

View File

@@ -0,0 +1,29 @@
import { MigrationInterface, QueryRunner } from "typeorm";
/**
* Amounts now carry the real/major price (callers pass e.g. 10.50, not minor units), which may be
* fractional. Widen amount_minor / confirmed_amount_minor from integer to double precision so the
* decimals are stored instead of silently rounded.
*/
export class AmountToDouble1782000000000 implements MigrationInterface {
name = "AmountToDouble1782000000000";
public async up(queryRunner: QueryRunner): Promise<void> {
// integer -> double precision is an implicit widening cast (no USING needed).
await queryRunner.query(
`ALTER TABLE "edr_payment"."payment_intent" ALTER COLUMN "amount_minor" TYPE double precision`,
);
await queryRunner.query(
`ALTER TABLE "edr_payment"."payment_intent" ALTER COLUMN "confirmed_amount_minor" TYPE double precision`,
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "edr_payment"."payment_intent" ALTER COLUMN "confirmed_amount_minor" TYPE integer USING round("confirmed_amount_minor")`,
);
await queryRunner.query(
`ALTER TABLE "edr_payment"."payment_intent" ALTER COLUMN "amount_minor" TYPE integer USING round("amount_minor")`,
);
}
}