-
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.
Merge branch 'main' into enhancement/#4270-sfas-bridge-expansion-db-m…
…igration
- Loading branch information
Showing
29 changed files
with
627 additions
and
4 deletions.
There are no files selected for viewing
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
21 changes: 21 additions & 0 deletions
21
...nd/apps/db-migrations/src/migrations/1737512317657-CreateCASInvoiceBatchApprovalStatus.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 CreateCASInvoiceBatchApprovalStatus1737512317657 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData("Create-cas-invoice-batch-approval-status.sql", "Types"), | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData( | ||
"Rollback-create-cas-invoice-batch-approval-status.sql", | ||
"Types", | ||
), | ||
); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ackages/backend/apps/db-migrations/src/migrations/1737512342015-CreateCASInvoiceStatus.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 CreateCASInvoiceStatus1737512342015 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData("Create-cas-invoice-status.sql", "Types"), | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData("Rollback-create-cas-invoice-status.sql", "Types"), | ||
); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...end/apps/db-migrations/src/migrations/1737512369084-CreateCASDistributionAccountsTable.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 CreateCASDistributionAccountsTable1737512369084 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData( | ||
"Create-cas-distribution-accounts.sql", | ||
"CASDistributionAccounts", | ||
), | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData( | ||
"Rollback-create-cas-distribution-accounts.sql", | ||
"CASDistributionAccounts", | ||
), | ||
); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...s/backend/apps/db-migrations/src/migrations/1737512385624-CreateCASInvoiceBatchesTable.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 CreateCASInvoiceBatchesTable1737512385624 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData("Create-cas-invoice-batches.sql", "CASInvoiceBatches"), | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData( | ||
"Rollback-create-cas-invoice-batches.sql", | ||
"CASInvoiceBatches", | ||
), | ||
); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ackages/backend/apps/db-migrations/src/migrations/1737512396375-CreateCASInvoicesTable.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 CreateCASInvoicesTable1737512396375 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData("Create-cas-invoices.sql", "CASInvoices"), | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData("Rollback-create-cas-invoices.sql", "CASInvoices"), | ||
); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...s/backend/apps/db-migrations/src/migrations/1737512408850-CreateCASInvoiceDetailsTable.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 CreateCASInvoiceDetailsTable1737512408850 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData("Create-cas-invoice-details.sql", "CASInvoiceDetails"), | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData( | ||
"Rollback-create-cas-invoice-details.sql", | ||
"CASInvoiceDetails", | ||
), | ||
); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...d/apps/db-migrations/src/sql/CASDistributionAccounts/Create-cas-distribution-accounts.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,46 @@ | ||
CREATE TABLE sims.cas_distribution_accounts( | ||
id SERIAL PRIMARY KEY, | ||
award_value_code VARCHAR(10) NOT NULL, | ||
offering_intensity sims.offering_intensity NOT NULL, | ||
operation_code CHAR(2) NOT NULL, | ||
distribution_account VARCHAR(40) NOT NULL, | ||
is_active BOOLEAN NOT NULL, | ||
-- Audit columns | ||
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
creator INT NOT NULL DEFAULT NULL REFERENCES sims.users(id), | ||
modifier INT NULL DEFAULT NULL REFERENCES sims.users(id) | ||
); | ||
|
||
CREATE UNIQUE INDEX cas_distribution_accounts_award_value_code_offering_intensity_operation_code ON sims.cas_distribution_accounts( | ||
award_value_code, | ||
offering_intensity, | ||
operation_code | ||
) | ||
WHERE | ||
(is_active = TRUE); | ||
|
||
-- ## Comments | ||
COMMENT ON INDEX sims.cas_distribution_accounts_award_value_code_offering_intensity_operation_code IS 'Ensures only one distribution account record will be active for an award code for a particular offering intensity and operation code.'; | ||
|
||
COMMENT ON TABLE sims.cas_distribution_accounts IS 'CAS distribution account information to be reported in invoice details.'; | ||
|
||
COMMENT ON COLUMN sims.cas_distribution_accounts.id IS 'Auto-generated sequential primary key column.'; | ||
|
||
COMMENT ON COLUMN sims.cas_distribution_accounts.award_value_code IS 'SIMS award value codes.'; | ||
|
||
COMMENT ON COLUMN sims.cas_distribution_accounts.offering_intensity IS 'Offering intensity to allow same awards to potentially have different distribution accounts for a same award code.'; | ||
|
||
COMMENT ON COLUMN sims.cas_distribution_accounts.operation_code IS 'Codes for the operations, expected to be "DR" for debit and "CR" for credit.'; | ||
|
||
COMMENT ON COLUMN sims.cas_distribution_accounts.distribution_account IS 'Distribution account.'; | ||
|
||
COMMENT ON COLUMN sims.cas_distribution_accounts.is_active IS 'Indicates if the distribution account for the award code is active. One pair of distribution accounts are expected to each award code (one for debit and one for credit).'; | ||
|
||
COMMENT ON COLUMN sims.cas_distribution_accounts.created_at IS 'Record creation timestamp.'; | ||
|
||
COMMENT ON COLUMN sims.cas_distribution_accounts.updated_at IS 'Record update timestamp.'; | ||
|
||
COMMENT ON COLUMN sims.cas_distribution_accounts.creator IS 'Creator of the record.'; | ||
|
||
COMMENT ON COLUMN sims.cas_distribution_accounts.modifier IS 'Modifier of the record.'; |
1 change: 1 addition & 0 deletions
1
...-migrations/src/sql/CASDistributionAccounts/Rollback-create-cas-distribution-accounts.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 @@ | ||
DROP TABLE sims.cas_distribution_accounts; |
37 changes: 37 additions & 0 deletions
37
...kages/backend/apps/db-migrations/src/sql/CASInvoiceBatches/Create-cas-invoice-batches.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,37 @@ | ||
CREATE TABLE sims.cas_invoice_batches( | ||
id SERIAL PRIMARY KEY, | ||
batch_name VARCHAR(50) NOT NULL, | ||
batch_date TIMESTAMP WITH TIME ZONE NOT NULL, | ||
approval_status sims.cas_invoice_batch_approval_status NOT NULL, | ||
approval_status_updated_on TIMESTAMP WITH TIME ZONE NOT NULL, | ||
approval_status_updated_by INT NOT NULL REFERENCES sims.users(id), | ||
-- Audit columns | ||
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
creator INT NOT NULL REFERENCES sims.users(id), | ||
modifier INT NULL DEFAULT NULL REFERENCES sims.users(id), | ||
UNIQUE (batch_name) | ||
); | ||
|
||
-- ## Comments | ||
COMMENT ON TABLE sims.cas_invoice_batches IS 'CAS batch information to group disbursement invoices.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoice_batches.id IS 'Auto-generated sequential primary key column.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoice_batches.batch_name IS 'Unique batch name.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoice_batches.batch_date IS 'Batch date.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoice_batches.approval_status IS 'Approval status.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoice_batches.approval_status_updated_on IS 'Last date and time when the status changed.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoice_batches.approval_status_updated_by IS 'User that changed the status last time.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoice_batches.created_at IS 'Record creation timestamp.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoice_batches.updated_at IS 'Record update timestamp.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoice_batches.creator IS 'Creator of the record.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoice_batches.modifier IS 'Modifier of the record.'; |
1 change: 1 addition & 0 deletions
1
...kend/apps/db-migrations/src/sql/CASInvoiceBatches/Rollback-create-cas-invoice-batches.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 @@ | ||
DROP TABLE sims.cas_invoice_batches; |
31 changes: 31 additions & 0 deletions
31
...kages/backend/apps/db-migrations/src/sql/CASInvoiceDetails/Create-cas-invoice-details.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,31 @@ | ||
CREATE TABLE sims.cas_invoice_details( | ||
id SERIAL PRIMARY KEY, | ||
cas_invoice_id INT NOT NULL REFERENCES sims.cas_invoices(id), | ||
cas_distribution_account_id INT NOT NULL REFERENCES sims.cas_distribution_accounts(id), | ||
value_amount NUMERIC(8, 2) NOT NULL, | ||
-- Audit columns | ||
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
creator INT NOT NULL REFERENCES sims.users(id), | ||
modifier INT NULL DEFAULT NULL REFERENCES sims.users(id), | ||
UNIQUE (cas_invoice_id, cas_distribution_account_id) | ||
); | ||
|
||
-- ## Comments | ||
COMMENT ON TABLE sims.cas_invoice_details IS 'CAS invoice details with every distribution account active for the award codes part of an e-Cert receipt.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoice_details.id IS 'Auto-generated sequential primary key column.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoice_details.cas_invoice_id IS 'Related invoice.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoice_details.cas_distribution_account_id IS 'Active distribution account for the award code.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoice_details.value_amount IS 'Award money value amount.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoice_details.created_at IS 'Record creation timestamp.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoice_details.updated_at IS 'Record update timestamp.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoice_details.creator IS 'Creator of the record.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoice_details.modifier IS 'Modifier of the record.'; |
1 change: 1 addition & 0 deletions
1
...kend/apps/db-migrations/src/sql/CASInvoiceDetails/Rollback-create-cas-invoice-details.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 @@ | ||
DROP TABLE sims.cas_invoice_details; |
43 changes: 43 additions & 0 deletions
43
sources/packages/backend/apps/db-migrations/src/sql/CASInvoices/Create-cas-invoices.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,43 @@ | ||
CREATE TABLE sims.cas_invoices( | ||
id SERIAL PRIMARY KEY, | ||
cas_invoice_batch_id INT NOT NULL REFERENCES sims.cas_invoice_batches(id), | ||
disbursement_receipt_id INT NOT NULL REFERENCES sims.disbursement_receipts(id), | ||
cas_supplier_id INT NOT NULL REFERENCES sims.cas_suppliers(id), | ||
invoice_number VARCHAR(40) NOT NULL, | ||
invoice_status sims.cas_invoice_status NOT NULL, | ||
invoice_status_updated_on TIMESTAMP WITH TIME ZONE NOT NULL, | ||
errors VARCHAR(300) [], | ||
-- Audit columns | ||
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
creator INT NOT NULL REFERENCES sims.users(id), | ||
modifier INT NULL DEFAULT NULL REFERENCES sims.users(id), | ||
UNIQUE (cas_supplier_id, invoice_number) | ||
); | ||
|
||
-- ## Comments | ||
COMMENT ON TABLE sims.cas_invoices IS 'CAS invoices related to an e-Cert receipt and part of a batch to be reported to CAS.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoices.id IS 'Auto-generated sequential primary key column.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoices.cas_invoice_batch_id IS 'Related batch that this invoice belongs to.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoices.disbursement_receipt_id IS 'e-Cert receipt that this invoice is related to.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoices.cas_supplier_id IS 'Active CAS supplier associated with the student at the moment the invoice was created.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoices.invoice_number IS 'Unique invoice number for a supplier.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoices.invoice_status IS 'Status of the invoice indicating if it was sent to CAS.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoices.invoice_status_updated_on IS 'Date and time when the invoice status was updated.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoices.errors IS 'Errors while sending invoices to CAS.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoices.created_at IS 'Record creation timestamp.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoices.updated_at IS 'Record update timestamp.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoices.creator IS 'Creator of the record.'; | ||
|
||
COMMENT ON COLUMN sims.cas_invoices.modifier IS 'Modifier of the record.'; |
1 change: 1 addition & 0 deletions
1
.../packages/backend/apps/db-migrations/src/sql/CASInvoices/Rollback-create-cas-invoices.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 @@ | ||
DROP TABLE sims.cas_invoices; |
1 change: 1 addition & 0 deletions
1
...ges/backend/apps/db-migrations/src/sql/Types/Create-cas-invoice-batch-approval-status.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 @@ | ||
CREATE TYPE sims.cas_invoice_batch_approval_status AS ENUM ('Pending', 'Approved', 'Rejected'); |
1 change: 1 addition & 0 deletions
1
sources/packages/backend/apps/db-migrations/src/sql/Types/Create-cas-invoice-status.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 @@ | ||
CREATE TYPE sims.cas_invoice_status AS ENUM ('Pending', 'Sent', 'Manual intervention'); |
1 change: 1 addition & 0 deletions
1
...nd/apps/db-migrations/src/sql/Types/Rollback-create-cas-invoice-batch-approval-status.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 @@ | ||
DROP TYPE sims.cas_invoice_batch_approval_status; |
1 change: 1 addition & 0 deletions
1
.../packages/backend/apps/db-migrations/src/sql/Types/Rollback-create-cas-invoice-status.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 @@ | ||
DROP TYPE sims.cas_invoice_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
Oops, something went wrong.