-
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.
#1753 - Add student notes during add manual overaward deduction - par…
…t 1 (#1772) * DB changes * renaming and comments * changed type to INT * changed timestamp to with tz
- Loading branch information
1 parent
4491c2e
commit c325d78
Showing
6 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...rations/src/migrations/1677801820875-AddNoteIdAddedByAddedDateToDisbursementOverawards.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,24 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
import { getSQLFileData } from "../utilities/sqlLoader"; | ||
|
||
export class AddNoteIdAddedByAddedDateToDisbursementOverawards1677801820875 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData( | ||
"Add-note-id-added-by-added-date.sql", | ||
"DisbursementOverawards", | ||
), | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData( | ||
"Remove-note-id-added-by-added-date.sql", | ||
"DisbursementOverawards", | ||
), | ||
); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
.../packages/backend/apps/db-migrations/src/migrations/1677805984987-AddNoteTypeOveraward.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,16 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
import { getSQLFileData } from "../utilities/sqlLoader"; | ||
|
||
export class AddNoteTypeOveraward1677805984987 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData("Add-note-type-overaward.sql", "Types"), | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData("Drop-note-type-overaward.sql", "Types"), | ||
); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...end/apps/db-migrations/src/sql/DisbursementOverawards/Add-note-id-added-by-added-date.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,23 @@ | ||
-- Add column note_id to sims.disbursement_overawards. | ||
ALTER TABLE | ||
sims.disbursement_overawards | ||
ADD | ||
COLUMN IF NOT EXISTS note_id INT REFERENCES sims.notes(id); | ||
|
||
COMMENT ON COLUMN sims.disbursement_overawards.note_id IS 'Note id for the disbursement overaward record.'; | ||
|
||
-- Add column added_by to sims.disbursement_overawards. | ||
ALTER TABLE | ||
sims.disbursement_overawards | ||
ADD | ||
COLUMN IF NOT EXISTS added_by INT REFERENCES sims.users(id); | ||
|
||
COMMENT ON COLUMN sims.disbursement_overawards.added_by IS 'User id of the user adding a manual record.'; | ||
|
||
-- Add column added_date to sims.disbursement_overawards. | ||
ALTER TABLE | ||
sims.disbursement_overawards | ||
ADD | ||
COLUMN IF NOT EXISTS added_date TIMESTAMP WITH TIME ZONE; | ||
|
||
COMMENT ON COLUMN sims.disbursement_overawards.added_date IS 'Date that the manual record was added.'; |
11 changes: 11 additions & 0 deletions
11
.../apps/db-migrations/src/sql/DisbursementOverawards/Remove-note-id-added-by-added-date.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,11 @@ | ||
-- Remove column note_id from sims.disbursement_overawards. | ||
ALTER TABLE | ||
sims.disbursement_overawards DROP COLUMN IF EXISTS note_id; | ||
|
||
-- Remove column added_by from sims.disbursement_overawards. | ||
ALTER TABLE | ||
sims.disbursement_overawards DROP COLUMN IF EXISTS added_by; | ||
|
||
-- Remove column added_date from sims.disbursement_overawards. | ||
ALTER TABLE | ||
sims.disbursement_overawards DROP COLUMN IF EXISTS added_date; |
6 changes: 6 additions & 0 deletions
6
sources/packages/backend/apps/db-migrations/src/sql/Types/Add-note-type-overaward.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,6 @@ | ||
-- Add Overaward to note types. | ||
ALTER TYPE sims.note_types | ||
ADD | ||
VALUE 'Overaward' | ||
AFTER | ||
'Designation'; |
27 changes: 27 additions & 0 deletions
27
sources/packages/backend/apps/db-migrations/src/sql/Types/Drop-note-type-overaward.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,27 @@ | ||
--Removing the value Overaward from sims.note_types for the rollback. | ||
--As postgres does not support removal of an Enum Value, We create a temporary enum and rename it. | ||
CREATE TYPE sims.note_types_to_rollback AS ENUM ( | ||
'General', | ||
'Application', | ||
'Program', | ||
'Restriction', | ||
'Designation', | ||
'System Actions' | ||
); | ||
|
||
-- Update the dependent column to start using the new enum with the expected values. | ||
ALTER TABLE | ||
sims.notes | ||
ALTER COLUMN | ||
note_type TYPE sims.note_types_to_rollback USING ( | ||
CASE | ||
note_type :: text | ||
WHEN 'Overaward' THEN 'General' | ||
ELSE note_type :: text | ||
END | ||
) :: sims.note_types_to_rollback; | ||
|
||
|
||
DROP TYPE sims.note_types; | ||
|
||
ALTER TYPE sims.note_types_to_rollback RENAME TO note_types; |