Skip to content

Commit

Permalink
#1753 - Add student notes during add manual overaward deduction - par…
Browse files Browse the repository at this point in the history
…t 1 (#1772)

* DB changes

* renaming and comments

* changed type to INT

* changed timestamp to with tz
  • Loading branch information
andrepestana-aot authored Mar 3, 2023
1 parent 4491c2e commit c325d78
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 0 deletions.
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",
),
);
}
}
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"),
);
}
}
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.';
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;
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';
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;

0 comments on commit c325d78

Please sign in to comment.