From d2732bca43a8c2392eb87e566bb0cef3f964081e Mon Sep 17 00:00:00 2001 From: hassan Date: Mon, 21 Sep 2020 10:16:39 +0300 Subject: [PATCH] TZUP-124: Add budgets table for facility budget file upload --- CHANGELOG.md | 5 +++++ ...0200921070050172__create_budgets_table.sql | 14 ++++++++++++ ...70742587__create_source_of_funds_table.sql | 13 +++++++++++ ...759440__create_budget_line_items_table.sql | 22 +++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 src/main/resources/db/migration/20200921070050172__create_budgets_table.sql create mode 100644 src/main/resources/db/migration/20200921070742587__create_source_of_funds_table.sql create mode 100644 src/main/resources/db/migration/20200921070759440__create_budget_line_items_table.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index 10879c9da..e9d9be7b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +9.0.0 / 2020-09-16 +================== +New functionality: +* [TZUP-124](https://openlmis.atlassian.net/browse/TZUP-124): Added budget, source of funds and budget line items migration script tables for facility budget file upload + 8.3.1 / WIP ================== diff --git a/src/main/resources/db/migration/20200921070050172__create_budgets_table.sql b/src/main/resources/db/migration/20200921070050172__create_budgets_table.sql new file mode 100644 index 000000000..ed2b7e776 --- /dev/null +++ b/src/main/resources/db/migration/20200921070050172__create_budgets_table.sql @@ -0,0 +1,14 @@ +-- WHEN COMMITTING OR REVIEWING THIS FILE: Make sure that the timestamp in the file name (that serves as a version) is the latest timestamp, and that no new migration have been added in the meanwhile. +-- Adding migrations out of order may cause this migration to never execute or behave in an unexpected way. +-- Migrations should NOT BE EDITED. Add a new migration to apply changes. + +CREATE TABLE budgets ( + id uuid NOT NULL, + facilityid uuid NOT NULL, + sourceapplication character varying(50) NOT NULL UNIQUE, + createdby uuid NOT NULL, + createddate timestamp with time zone NOT NULL DEFAULT 'now()', + modifiedby uuid NOT NULL, + modifieddate timestamp with time zone NOT NULL DEFAULT 'NOW()', + CONSTRAINT budgets_pk PRIMARY KEY (id) +); \ No newline at end of file diff --git a/src/main/resources/db/migration/20200921070742587__create_source_of_funds_table.sql b/src/main/resources/db/migration/20200921070742587__create_source_of_funds_table.sql new file mode 100644 index 000000000..9193ff41f --- /dev/null +++ b/src/main/resources/db/migration/20200921070742587__create_source_of_funds_table.sql @@ -0,0 +1,13 @@ +-- WHEN COMMITTING OR REVIEWING THIS FILE: Make sure that the timestamp in the file name (that serves as a version) is the latest timestamp, and that no new migration have been added in the meanwhile. +-- Adding migrations out of order may cause this migration to never execute or behave in an unexpected way. +-- Migrations should NOT BE EDITED. Add a new migration to apply changes. + +CREATE TABLE source_of_funds ( + id uuid NOT NULL, + code character varying(200) NOT NULL UNIQUE, + name character varying(200) NOT NULL UNIQUE, + createdDate timestamp with time zone NOT NULL DEFAULT 'NOW()', + modifiedDate timestamp with time zone NOT NULL DEFAULT 'NOW()', + displayOrder uuid NOT NULL, + CONSTRAINT source_of_funds_pk PRIMARY KEY (id) +); \ No newline at end of file diff --git a/src/main/resources/db/migration/20200921070759440__create_budget_line_items_table.sql b/src/main/resources/db/migration/20200921070759440__create_budget_line_items_table.sql new file mode 100644 index 000000000..2c071b879 --- /dev/null +++ b/src/main/resources/db/migration/20200921070759440__create_budget_line_items_table.sql @@ -0,0 +1,22 @@ +-- WHEN COMMITTING OR REVIEWING THIS FILE: Make sure that the timestamp in the file name (that serves as a version) is the latest timestamp, and that no new migration have been added in the meanwhile. +-- Adding migrations out of order may cause this migration to never execute or behave in an unexpected way. +-- Migrations should NOT BE EDITED. Add a new migration to apply changes. + + +CREATE TABLE budget_line_items ( + id uuid NOT NULL, + budgetid uuid NOT NULL, + fundsourceid uuid NOT NULL, + allocatedbudget numeric NOT NULL, + additive BOOLEAN NOT NULL DEFAULT 'true', + creditvalue character varying(100) NOT NULL, + notes character varying(255) NOT NULL, + createdby uuid NOT NULL, + createddate timestamp with time zone NOT NULL DEFAULT 'NOW()', + modifiedby uuid NOT NULL, + modifieddate timestamp with time zone NOT NULL DEFAULT 'NOW()', + CONSTRAINT budget_line_items_pk PRIMARY KEY (id) +); + +ALTER TABLE budget_line_items ADD CONSTRAINT fk_budget_line_items_budget_id FOREIGN KEY (budgetid) REFERENCES budgets(id); +ALTER TABLE budget_line_items ADD CONSTRAINT fk_budget_line_items_fund_source_id FOREIGN KEY (fundsourceid) REFERENCES source_of_funds(id);