Skip to content

Commit

Permalink
#4270 - Update the Data Types to adapt to import (#4329)
Browse files Browse the repository at this point in the history
As per the testing done from SFAS file, data type of the following DB
columns have been updated.

- [x] `sims.sfas_individuals` - column `phone_number` changed to BIGINT.
- [x] `sims.sfas_applications` - column `application_number` changed to
BIGINT.
- [x] `sims.sfas_applications` - column `gross_income_previous_year`
changed to NUMERIC(10,2).
- [x] Numeric transformer was used wherever required.

**Note**: Type casting wasn't used in the data type conversion expecting
no data in the columns.

## Rollback Evidence


![image](https://github.com/user-attachments/assets/5542ca83-c23d-4d46-a289-5647c4c54c41)


![image](https://github.com/user-attachments/assets/badebe05-e700-4ca4-a3da-cee1bb8201cb)
  • Loading branch information
dheepak-aot authored Feb 7, 2025
1 parent 7ce8ff9 commit ba12ce8
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { MigrationInterface, QueryRunner } from "typeorm";
import { getSQLFileData } from "../utilities/sqlLoader";

export class AlterSFASIndividualExpansionColumnType1738899779713
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
getSQLFileData("Alter-phone-number-type.sql", "SFASIndividuals"),
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
getSQLFileData("Rollback-alter-phone-number-type.sql", "SFASIndividuals"),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { MigrationInterface, QueryRunner } from "typeorm";
import { getSQLFileData } from "../utilities/sqlLoader";

export class AlterSFASApplicationExpansionColumnType1738900082886
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
getSQLFileData("Alter-expansion-columns-type.sql", "SFASApplications"),
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
getSQLFileData(
"Rollback-alter-expansion-columns-type.sql",
"SFASApplications",
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ALTER TABLE
sims.sfas_applications
ALTER COLUMN
application_number TYPE BIGINT;

ALTER TABLE
sims.sfas_applications
ALTER COLUMN
gross_income_previous_year TYPE NUMERIC(10, 2);
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ALTER TABLE
sims.sfas_applications
ALTER COLUMN
application_number TYPE INT;

ALTER TABLE
sims.sfas_applications
ALTER COLUMN
gross_income_previous_year TYPE INT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ALTER TABLE
sims.sfas_individuals
ALTER COLUMN
phone_number TYPE BIGINT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ALTER TABLE
sims.sfas_individuals
ALTER COLUMN
phone_number TYPE INT;
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ export class SFASIntegrationProcessingService {
for (const filePath of filePaths) {
await this.processFile(filePath, processSummary);
}
if (!filePaths.length) {
processSummary.info(
"There are no files to be processed, but post-file import operations will be executed.",
);
}
await this.postFileImportOperations(!!filePaths.length, processSummary);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ export class SFASApplication extends BaseSFASApplicationModel {
*/
@Column({
name: "application_number",
type: "bigint",
nullable: true,
transformer: numericTransformer,
})
applicationNumber?: number;

Expand Down Expand Up @@ -191,7 +193,9 @@ export class SFASApplication extends BaseSFASApplicationModel {
*/
@Column({
name: "gross_income_previous_year",
type: "numeric",
nullable: true,
transformer: numericTransformer,
})
grossIncomePreviousYear?: number;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,9 @@ export class SFASIndividual extends BaseModel {
*/
@Column({
name: "phone_number",
type: "bigint",
nullable: true,
transformer: numericTransformer,
})
phoneNumber?: number;
/**
Expand Down

0 comments on commit ba12ce8

Please sign in to comment.