-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add last name translations and new enum type.
- Loading branch information
1 parent
22c9313
commit d2d6eaa
Showing
8 changed files
with
238 additions
and
109 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
...d/apps/db-migrations/src/migrations/1728327203709-AddManualInterventionCASSupplierType.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 AddManualInterventionCASSupplierType1728327203709 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData("Add-manual-intervention-cas-supplier-type.sql", "Types"), | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData( | ||
"Rollback-add-manual-intervention-cas-supplier-type.sql", | ||
"Types", | ||
), | ||
); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...es/backend/apps/db-migrations/src/sql/Types/Add-manual-intervention-cas-supplier-type.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- Postgres allows adding new types to an enum but it causes issues when the new types added are | ||
-- used in another query in the same transaction, hence the team decision was to recreate the enums | ||
-- types when a new item must be added following the same approach already used for rollbacks. | ||
CREATE TYPE sims.supplier_status_to_be_updated AS ENUM ( | ||
'Pending supplier verification', | ||
'Pending address verification', | ||
'Verified', | ||
'Verified manually', | ||
'Manual intervention' | ||
); | ||
|
||
-- Update the dependent column to start using the new enum with the expected values. | ||
ALTER TABLE | ||
sims.cas_suppliers | ||
ALTER COLUMN | ||
supplier_status TYPE sims.supplier_status_to_be_updated USING (supplier_status :: TEXT) :: sims.supplier_status_to_be_updated; | ||
|
||
-- Remove the entire enum that is no longer being used. | ||
DROP TYPE sims.supplier_status; | ||
|
||
-- Rename the enum to what it was in the beginning. | ||
ALTER TYPE sims.supplier_status_to_be_updated RENAME TO supplier_status; |
21 changes: 21 additions & 0 deletions
21
...d/apps/db-migrations/src/sql/Types/Rollback-add-manual-intervention-cas-supplier-type.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-- Postgres allows adding new types to an enum but it causes issues when the new types added are | ||
-- used in another query in the same transaction, hence the team decision was to recreate the enums | ||
-- types when a new item must be added following the same approach already used for rollbacks. | ||
CREATE TYPE sims.supplier_status_to_be_updated AS ENUM ( | ||
'Pending supplier verification', | ||
'Pending address verification', | ||
'Verified', | ||
'Verified manually' | ||
); | ||
|
||
-- Update the dependent column to start using the new enum with the expected values. | ||
ALTER TABLE | ||
sims.cas_suppliers | ||
ALTER COLUMN | ||
supplier_status TYPE sims.supplier_status_to_be_updated USING (supplier_status :: TEXT) :: sims.supplier_status_to_be_updated; | ||
|
||
-- Remove the entire enum that is no longer being used. | ||
DROP TYPE sims.supplier_status; | ||
|
||
-- Rename the enum to what it was in the beginning. | ||
ALTER TYPE sims.supplier_status_to_be_updated RENAME TO supplier_status; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...es/packages/backend/libs/utilities/src/_tests_/unit/string-utils.translateToASCII.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { translateToASCII } from "@sims/utilities/string-utils"; | ||
|
||
describe("StringUtils-translateToASCII", () => { | ||
it("Should replace the special characters when equivalent ones are present.", () => { | ||
// Arrange | ||
const textWithSpecialCharacters = | ||
"Some text with special characters: ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜ—àáâãäåçèéêëìíîï-ñóòôõöùúûüýÿ"; | ||
|
||
// Act | ||
const translatedData = translateToASCII(textWithSpecialCharacters); | ||
|
||
// Assert | ||
expect(translatedData).toBe( | ||
"Some text with special characters: AAAAAACEEEEIIIINOOOOOUUUU-aaaaaaceeeeiiii-nooooouuuuyy", | ||
); | ||
}); | ||
|
||
it("Should return null when null is provided.", () => { | ||
// Arrange | ||
const textWithSpecialCharacters = null; | ||
|
||
// Act | ||
const translatedData = translateToASCII(textWithSpecialCharacters); | ||
|
||
// Assert | ||
expect(translatedData).toBeNull(); | ||
}); | ||
|
||
it("Should return null when undefined is provided.", () => { | ||
// Arrange | ||
const textWithSpecialCharacters = undefined; | ||
|
||
// Act | ||
const translatedData = translateToASCII(textWithSpecialCharacters); | ||
|
||
// Assert | ||
expect(translatedData).toBeNull(); | ||
}); | ||
}); |
Oops, something went wrong.