mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 20:40:55 +00:00
46 lines
1.9 KiB
TypeScript
46 lines
1.9 KiB
TypeScript
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
|
|
/**
|
|
* CBE Unified Bill Payment (docs/cbe/CBE_IMPLEMENTATION_PLAN.md §4.1, §5):
|
|
* - `bill_reference` — the short numeric Bill_Id CBE presents back to us; unique, null for
|
|
* every non-CBE intent.
|
|
* - `payer_name` — payer snapshot captured at initiate; fallback for /cbe/query Full_Name.
|
|
* - `cbe_bill_reference_seq` — backs the 11-digit sequence body of the bill reference.
|
|
*
|
|
* DATA SAFETY: purely additive — new nullable columns and a new sequence; no existing rows
|
|
* or values are touched.
|
|
*/
|
|
export class AddCbeBillReference1782300000000 implements MigrationInterface {
|
|
name = "AddCbeBillReference1782300000000";
|
|
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
await queryRunner.query(
|
|
`ALTER TABLE "edr_payment"."payment_intent" ADD COLUMN IF NOT EXISTS "bill_reference" varchar(32)`,
|
|
);
|
|
await queryRunner.query(
|
|
`ALTER TABLE "edr_payment"."payment_intent" ADD COLUMN IF NOT EXISTS "payer_name" varchar(128)`,
|
|
);
|
|
await queryRunner.query(
|
|
`CREATE UNIQUE INDEX IF NOT EXISTS "uq_payment_intent_bill_reference" ON "edr_payment"."payment_intent" ("bill_reference") WHERE "bill_reference" IS NOT NULL`,
|
|
);
|
|
await queryRunner.query(
|
|
`CREATE SEQUENCE IF NOT EXISTS "edr_payment"."cbe_bill_reference_seq" START 10000001`,
|
|
);
|
|
}
|
|
|
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
await queryRunner.query(
|
|
`DROP SEQUENCE IF EXISTS "edr_payment"."cbe_bill_reference_seq"`,
|
|
);
|
|
await queryRunner.query(
|
|
`DROP INDEX IF EXISTS "edr_payment"."uq_payment_intent_bill_reference"`,
|
|
);
|
|
await queryRunner.query(
|
|
`ALTER TABLE "edr_payment"."payment_intent" DROP COLUMN IF EXISTS "payer_name"`,
|
|
);
|
|
await queryRunner.query(
|
|
`ALTER TABLE "edr_payment"."payment_intent" DROP COLUMN IF EXISTS "bill_reference"`,
|
|
);
|
|
}
|
|
}
|