diff --git a/src/migrations/1765877128065-AddNationalIdToKycTransactions.ts b/src/migrations/1765877128065-AddNationalIdToKycTransactions.ts deleted file mode 100644 index f6a313b..0000000 --- a/src/migrations/1765877128065-AddNationalIdToKycTransactions.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddNationalIdToKycTransactions1765877128065 implements MigrationInterface { - name = 'AddNationalIdToKycTransactions1765877128065' - - public async up(queryRunner: QueryRunner): Promise { - // Add column as nullable first (to handle existing records) - await queryRunner.query(`ALTER TABLE "kyc_transactions" ADD "national_id" character varying(50)`); - - // Backfill existing records from form_data->poiNumber - await queryRunner.query(` - UPDATE "kyc_transactions" - SET "national_id" = form_data->>'poiNumber' - WHERE "national_id" IS NULL AND form_data->>'poiNumber' IS NOT NULL - `); - - // Now make it NOT NULL with a default empty string for safety - await queryRunner.query(`ALTER TABLE "kyc_transactions" ALTER COLUMN "national_id" SET DEFAULT ''`); - await queryRunner.query(`ALTER TABLE "kyc_transactions" ALTER COLUMN "national_id" SET NOT NULL`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "kyc_transactions" DROP COLUMN "national_id"`); - } - -}