From cfd02e8c300448ab676f3d9044482c4124f1be4d Mon Sep 17 00:00:00 2001 From: Abdalhamid Alhamad Date: Tue, 16 Dec 2025 16:40:13 +0300 Subject: [PATCH] refactor: remove obsolete customer fields and update migration - Removed unused fields: sourceOfIncome, profession, and professionType from Customer entity and DTOs. - Updated KYC callback mock to reflect the removal of professionType. - Added migration to drop the corresponding columns from the database. --- .../neoleap/__mocks__/kyc-callback.mock.ts | 1 - .../dtos/response/customer.response.dto.ts | 12 ---------- src/customer/entities/customer.entity.ts | 9 -------- .../1765891028260-RemoveOldCustomerColumns.ts | 23 +++++++++++++++++++ src/db/migrations/index.ts | 3 ++- 5 files changed, 25 insertions(+), 23 deletions(-) create mode 100644 src/db/migrations/1765891028260-RemoveOldCustomerColumns.ts diff --git a/src/common/modules/neoleap/__mocks__/kyc-callback.mock.ts b/src/common/modules/neoleap/__mocks__/kyc-callback.mock.ts index 88d4e5b..3bd6b45 100644 --- a/src/common/modules/neoleap/__mocks__/kyc-callback.mock.ts +++ b/src/common/modules/neoleap/__mocks__/kyc-callback.mock.ts @@ -17,7 +17,6 @@ export const getKycCallbackMock = (nationalId: string) => { salaryMax: '1000', incomeSource: 'Salary', professionTitle: 'Software Engineer', - professionType: 'Full-Time', isPep: 'N', country: '682', region: 'Mecca', diff --git a/src/customer/dtos/response/customer.response.dto.ts b/src/customer/dtos/response/customer.response.dto.ts index 82bfe91..3ed0423 100644 --- a/src/customer/dtos/response/customer.response.dto.ts +++ b/src/customer/dtos/response/customer.response.dto.ts @@ -34,15 +34,6 @@ export class CustomerResponseDto { @ApiProperty({ example: 'JO' }) countryOfResidence!: string; - @ApiProperty({ example: 'Employee' }) - sourceOfIncome!: string; - - @ApiProperty({ example: 'Software Development' }) - profession!: string; - - @ApiProperty({ example: 'Full-time' }) - professionType!: string; - @ApiProperty({ example: false }) isPep!: boolean; @@ -90,9 +81,6 @@ export class CustomerResponseDto { this.nationalId = customer.nationalId; this.nationalIdExpiry = customer.nationalIdExpiry; this.countryOfResidence = customer.countryOfResidence; - this.sourceOfIncome = customer.sourceOfIncome; - this.profession = customer.profession; - this.professionType = customer.professionType; this.isPep = customer.isPep; this.gender = customer.gender; this.isJunior = customer.isJunior; diff --git a/src/customer/entities/customer.entity.ts b/src/customer/entities/customer.entity.ts index cd263ae..ae381ae 100644 --- a/src/customer/entities/customer.entity.ts +++ b/src/customer/entities/customer.entity.ts @@ -49,15 +49,6 @@ export class Customer extends BaseEntity { @Column('varchar', { length: 255, nullable: true, name: 'country_of_residence' }) countryOfResidence!: CountryIso; - @Column('varchar', { length: 255, nullable: true, name: 'source_of_income' }) - sourceOfIncome!: string; - - @Column('varchar', { length: 255, nullable: true, name: 'profession' }) - profession!: string; - - @Column('varchar', { length: 255, nullable: true, name: 'profession_type' }) - professionType!: string; - @Column('boolean', { default: false, name: 'is_pep' }) isPep!: boolean; diff --git a/src/db/migrations/1765891028260-RemoveOldCustomerColumns.ts b/src/db/migrations/1765891028260-RemoveOldCustomerColumns.ts new file mode 100644 index 0000000..46f0948 --- /dev/null +++ b/src/db/migrations/1765891028260-RemoveOldCustomerColumns.ts @@ -0,0 +1,23 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class RemoveOldCustomerColumns1765891028260 implements MigrationInterface { + name = 'RemoveOldCustomerColumns1765891028260'; + + public async up(queryRunner: QueryRunner): Promise { + // Remove duplicate/unused columns that were replaced by KYC-specific fields + // source_of_income -> replaced by income_source + // profession -> replaced by job_sector + // profession_type -> replaced by job_category + await queryRunner.query(`ALTER TABLE "customers" DROP COLUMN IF EXISTS "source_of_income"`); + await queryRunner.query(`ALTER TABLE "customers" DROP COLUMN IF EXISTS "profession"`); + await queryRunner.query(`ALTER TABLE "customers" DROP COLUMN IF EXISTS "profession_type"`); + } + + public async down(queryRunner: QueryRunner): Promise { + // Restore columns if migration is rolled back + await queryRunner.query(`ALTER TABLE "customers" ADD "source_of_income" character varying(255)`); + await queryRunner.query(`ALTER TABLE "customers" ADD "profession" character varying(255)`); + await queryRunner.query(`ALTER TABLE "customers" ADD "profession_type" character varying(255)`); + } +} + diff --git a/src/db/migrations/index.ts b/src/db/migrations/index.ts index 304fdd0..9816012 100644 --- a/src/db/migrations/index.ts +++ b/src/db/migrations/index.ts @@ -7,4 +7,5 @@ export * from './1757915357218-add-deleted-at-column-to-junior'; export * from './1760869651296-AddMerchantInfoToTransactions'; export * from './1761032305682-AddUniqueConstraintToUserEmail'; export * from './1765804942393-AddKycFieldsAndTransactions'; -export * from './1765877128065-AddNationalIdToKycTransactions'; \ No newline at end of file +export * from './1765877128065-AddNationalIdToKycTransactions'; +export * from './1765891028260-RemoveOldCustomerColumns'; \ No newline at end of file