From def70d262b9efbfe5c7452d50b40e4bde991ba4a Mon Sep 17 00:00:00 2001 From: ssylver93 <107515688+ssylver93@users.noreply.github.com> Date: Mon, 30 Dec 2024 10:14:55 -0800 Subject: [PATCH] Feature/wfprev 193 (#382) (#383) Co-authored-by: Henry Saldyga --- db/app_wf1_prev-changelog.json | 31 ++++++++ .../01_00_03/00/ddl/WFPREV.alter_project.sql | 32 ++++++++ .../ddl/WFPREV.create_objective_type_code.sql | 75 +++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 db/scripts/01_00_03/00/ddl/WFPREV.alter_project.sql create mode 100644 db/scripts/01_00_03/00/ddl/WFPREV.create_objective_type_code.sql diff --git a/db/app_wf1_prev-changelog.json b/db/app_wf1_prev-changelog.json index f7d5afb83..a32891e33 100644 --- a/db/app_wf1_prev-changelog.json +++ b/db/app_wf1_prev-changelog.json @@ -242,6 +242,37 @@ { "sql": "DROP SEQUENCE wfprev.project_number_seq" } ] } + }, + { + "changeSet": { + "id": "01_00_03_00", + "author": "hsaldyga", + "tagDatabase": { "tag" : "version_01_00_03_00" }, + "changes": [ + { + "sqlFile": { + "dbms": "postgresql", + "endDelimiter": ";", + "path": "scripts/01_00_03/00/ddl/WFPREV.create_objective_type_code.sql" + } + }, + { + "sqlFile": { + "dbms": "postgresql", + "endDelimiter": ";", + "path": "scripts/01_00_03/00/ddl/WFPREV.alter_project.sql" + } + } + ], + "rollback": [ + { "sql": "ALTER TABLE wfprev.project DROP COLUMN primary_objective_type_code" }, + { "sql": "ALTER TABLE wfprev.project DROP COLUMN secondary_objective_type_code" }, + { "sql": "ALTER TABLE wfprev.project DROP COLUMN secondary_objective_rationale" }, + { "sql": "ALTER TABLE wfprev.project DROP COLUMN tertiary_objective_type_code" }, + { "sql": "ALTER TABLE wfprev.project DROP COLUMN tertiary_objective_rationale" }, + { "sql": "DROP TABLE wfprev.objective_type_code" } + ] + } } ] } \ No newline at end of file diff --git a/db/scripts/01_00_03/00/ddl/WFPREV.alter_project.sql b/db/scripts/01_00_03/00/ddl/WFPREV.alter_project.sql new file mode 100644 index 000000000..b268d0109 --- /dev/null +++ b/db/scripts/01_00_03/00/ddl/WFPREV.alter_project.sql @@ -0,0 +1,32 @@ +ALTER TABLE "wfprev"."project" ADD COLUMN "primary_objective_type_code" varchar(10); +COMMENT ON COLUMN "wfprev"."project"."primary_objective_type_code" + IS 'primary_objective_type_code: Is a foreign key to objective_type_code: Objective Type Code is the set of objectives that are desired outcomes for a project. Values are: - Wildfire Risk Reduction - Critical Infrastructure - Ecosystem Restoration - Egress/Evacuation - Forest Health - Hazard Abatement - Range Habitat Management - Reconciliation - Wildfire Habitat Management - Other'; +CREATE INDEX "prjct_objtcd_primary_idx" ON "wfprev"."project" ("primary_objective_type_code" ASC); +ALTER TABLE "wfprev"."project" ADD CONSTRAINT "prjct_objtcd_primary_fk" + FOREIGN KEY ("primary_objective_type_code") REFERENCES "wfprev"."objective_type_code" ("objective_type_code") ON DELETE No Action ON UPDATE No Action; + +ALTER TABLE "wfprev"."project" ADD COLUMN "secondary_objective_type_code" varchar(10); +COMMENT ON COLUMN "wfprev"."project"."secondary_objective_type_code" + IS 'secondary_objective_type_code: Is a foreign key to objective_type_code: Objective Type Code is the set of objectives that are desired outcomes for a project. Values are: - Wildfire Risk Reduction - Critical Infrastructure - Ecosystem Restoration - Egress/Evacuation - Forest Health - Hazard Abatement - Range Habitat Management - Reconciliation - Wildfire Habitat Management - Other'; +CREATE INDEX "prjct_objtcd_secondary_idx" ON "wfprev"."project" ("secondary_objective_type_code" ASC); +ALTER TABLE "wfprev"."project" ADD CONSTRAINT "prjct_objtcd_secondary_fk" + FOREIGN KEY ("secondary_objective_type_code") REFERENCES "wfprev"."objective_type_code" ("objective_type_code") ON DELETE No Action ON UPDATE No Action; + +ALTER TABLE "wfprev"."project" ADD COLUMN "secondary_objective_rationale" varchar(200); +COMMENT ON COLUMN "wfprev"."project"."secondary_objective_rationale" + IS 'Secondary Objective Rationale may be supplied when a Secondary Objective Type code is specified.'; + +ALTER TABLE "wfprev"."project" ADD COLUMN "tertiary_objective_type_code" varchar(10); +COMMENT ON COLUMN "wfprev"."project"."tertiary_objective_type_code" + IS 'tertiary_objective_type_code: Is a foreign key to objective_type_code: Objective Type Code is the set of objectives that are desired outcomes for a project. Values are: - Wildfire Risk Reduction - Critical Infrastructure - Ecosystem Restoration - Egress/Evacuation - Forest Health - Hazard Abatement - Range Habitat Management - Reconciliation - Wildfire Habitat Management - Other'; +CREATE INDEX "prjct_objtcd_tertiary_idx" ON "wfprev"."project" ("tertiary_objective_type_code" ASC); +ALTER TABLE "wfprev"."project" ADD CONSTRAINT "prjct_objtcd_tertiary_fk" + FOREIGN KEY ("tertiary_objective_type_code") REFERENCES "wfprev"."objective_type_code" ("objective_type_code") ON DELETE No Action ON UPDATE No Action; + +ALTER TABLE "wfprev"."project" ADD COLUMN "tertiary_objective_rationale" varchar(200); +COMMENT ON COLUMN "wfprev"."project"."tertiary_objective_rationale" + IS 'Tertiary Objective Rationale may be supplied when a Tertiary Objective Type code is specified.'; + + + + diff --git a/db/scripts/01_00_03/00/ddl/WFPREV.create_objective_type_code.sql b/db/scripts/01_00_03/00/ddl/WFPREV.create_objective_type_code.sql new file mode 100644 index 000000000..b787d3612 --- /dev/null +++ b/db/scripts/01_00_03/00/ddl/WFPREV.create_objective_type_code.sql @@ -0,0 +1,75 @@ +/* ---------------------------------------------------- */ +/* Generated by Enterprise Architect Version 12.0 */ +/* Created On : 10-Dec-2024 4:38:45 PM */ +/* DBMS : PostgreSQL */ +/* ---------------------------------------------------- */ + +/* Create Tables */ + +CREATE TABLE "wfprev"."objective_type_code" +( + "objective_type_code" varchar(10) NOT NULL, -- objective_type_code: Objective Type Code is the set of objectives that are desired outcomes for a project. Values are: - Wildfire Risk Reduction - Critical Infrastructure - Ecosystem Restoration - Egress/Evacuation - Forest Health - Hazard Abatement - Range Habitat Management - Reconciliation - Wildfire Habitat Management - Other + "description" varchar(200) NOT NULL, -- DESCRIPTION is the display quality description of the code value. + "display_order" decimal(3) NULL, -- DISPLAY ORDER is to allow non alphabetic sorting e.g. M T W Th F S S. + "effective_date" DATE NOT NULL DEFAULT CURRENT_DATE, -- EFFECTIVE_DATE is the date code value becomes effective. + "expiry_date" DATE NOT NULL DEFAULT '9999-12-31', -- EXPIRY_DATE is the date code value expires. + "revision_count" decimal(10) NOT NULL DEFAULT 0, -- REVISION_COUNT is the number of times that the row of data has been changed. The column is used for optimistic locking via application code. + "create_user" varchar(64) NOT NULL, -- CREATE_USER is an audit column that indicates the user that created the record. + "create_date" DATE NOT NULL DEFAULT CURRENT_TIMESTAMP, -- CREATE_DATE is the date and time the row of data was created. + "update_user" varchar(64) NOT NULL, -- UPDATE_USER is an audit column that indicates the user that updated the record. + "update_date" DATE NOT NULL DEFAULT CURRENT_TIMESTAMP -- UPDATE_DATE is the date and time the row of data was updated. +) +TABLESPACE PG_DEFAULT +; + +/* Create Table Comments, Sequences for Autonumber Columns */ + +COMMENT ON TABLE "wfprev"."objective_type_code" + IS 'Objective Type Code is the set of objectives that are desired outcomes for a project. Values are: - Wildfire Risk Reduction - Critical Infrastructure - Ecosystem Restoration - Egress/Evacuation - Forest Health - Hazard Abatement - Range Habitat Management - Reconciliation - Wildfire Habitat Management - Other' +; + +COMMENT ON COLUMN "wfprev"."objective_type_code"."objective_type_code" + IS 'objective_type_code: Objective Type Code is the set of objectives that are desired outcomes for a project. Values are: - Wildfire Risk Reduction - Critical Infrastructure - Ecosystem Restoration - Egress/Evacuation - Forest Health - Hazard Abatement - Range Habitat Management - Reconciliation - Wildfire Habitat Management - Other' +; + +COMMENT ON COLUMN "wfprev"."objective_type_code"."description" + IS 'DESCRIPTION is the display quality description of the code value.' +; + +COMMENT ON COLUMN "wfprev"."objective_type_code"."display_order" + IS 'DISPLAY ORDER is to allow non alphabetic sorting e.g. M T W Th F S S.' +; + +COMMENT ON COLUMN "wfprev"."objective_type_code"."effective_date" + IS 'EFFECTIVE_DATE is the date code value becomes effective.' +; + +COMMENT ON COLUMN "wfprev"."objective_type_code"."expiry_date" + IS 'EXPIRY_DATE is the date code value expires.' +; + +COMMENT ON COLUMN "wfprev"."objective_type_code"."revision_count" + IS 'REVISION_COUNT is the number of times that the row of data has been changed. The column is used for optimistic locking via application code.' +; + +COMMENT ON COLUMN "wfprev"."objective_type_code"."create_user" + IS 'CREATE_USER is an audit column that indicates the user that created the record.' +; + +COMMENT ON COLUMN "wfprev"."objective_type_code"."create_date" + IS 'CREATE_DATE is the date and time the row of data was created.' +; + +COMMENT ON COLUMN "wfprev"."objective_type_code"."update_user" + IS 'UPDATE_USER is an audit column that indicates the user that updated the record.' +; + +COMMENT ON COLUMN "wfprev"."objective_type_code"."update_date" + IS 'UPDATE_DATE is the date and time the row of data was updated.' +; + +/* Create Primary Keys, Indexes, Uniques, Checks */ + +ALTER TABLE "wfprev"."objective_type_code" ADD CONSTRAINT "objtcd_pk" + PRIMARY KEY ("objective_type_code") +; \ No newline at end of file