generated from hmcts/spring-boot-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PO-227 added the scripts to create log and audit tables and retention…
… period in configuration items table
- Loading branch information
1 parent
2446966
commit 51e4eca
Showing
9 changed files
with
335 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/main/resources/db/migration/V20240320_097__log_actions.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,26 @@ | ||
/** | ||
* CGI OPAL Program | ||
* | ||
* MODULE : log_actions.sql | ||
* | ||
* DESCRIPTION : Creates the LOG_ACTIONS table for the Fines model | ||
* | ||
* VERSION HISTORY: | ||
* | ||
* Date Author Version Nature of Change | ||
* ---------- ------- -------- ---------------------------------------------------------------------------- | ||
* 20/03/2024 A Dennis 1.0 PO-227 Creates the LOG_ACTIONS table for the Fines model | ||
* | ||
**/ | ||
CREATE TABLE log_actions | ||
( | ||
log_action_id smallint not null | ||
,log_action_name varchar(200) not null | ||
,CONSTRAINT log_actions_pk PRIMARY KEY | ||
( | ||
log_action_id | ||
) | ||
); | ||
|
||
COMMENT ON COLUMN log_actions.log_action_id IS 'Unique ID of this record'; | ||
COMMENT ON COLUMN log_actions.log_action_name IS 'The description of actions that could give rise to log creation'; |
15 changes: 15 additions & 0 deletions
15
src/main/resources/db/migration/V20240320_098__log_action_id_seq.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,15 @@ | ||
/** | ||
* OPAL Program | ||
* | ||
* MODULE : log_action_id_seq.sql | ||
* | ||
* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table LOG_ACTIONS. | ||
* | ||
* VERSION HISTORY: | ||
* | ||
* Date Author Version Nature of Change | ||
* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- | ||
* 20/03/2024 A Dennis 1.0 PO-227 Creates the Sequence to be used to generate the Primary key for the table LOG_ACTIONS | ||
* | ||
**/ | ||
CREATE SEQUENCE IF NOT EXISTS log_action_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY log_actions.log_action_id; |
66 changes: 66 additions & 0 deletions
66
src/main/resources/db/migration/V20240320_099__log_audit_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,66 @@ | ||
/** | ||
* CGI OPAL Program | ||
* | ||
* MODULE : log_audit_details.sql | ||
* | ||
* DESCRIPTION : Creates the LOG_AUDIT_DETAILS table for the Fines model | ||
* | ||
* VERSION HISTORY: | ||
* | ||
* Date Author Version Nature of Change | ||
* ---------- ------- -------- ---------------------------------------------------------------------------- | ||
* 20/03/2024 A Dennis 1.0 PO-227 Creates the LOG_AUDIT_DETAILS table for the Fines model | ||
* | ||
**/ | ||
CREATE TABLE log_audit_details | ||
( | ||
log_audit_detail_id bigint not null | ||
,user_id bigint not null | ||
,log_timestamp timestamp not null | ||
,log_action_id smallint not null | ||
,account_number varchar(20) | ||
,business_unit_id smallint | ||
,json_request text not null | ||
,CONSTRAINT log_audit_details_pk PRIMARY KEY | ||
( | ||
log_audit_detail_id | ||
) | ||
); | ||
|
||
ALTER TABLE log_audit_details | ||
ADD CONSTRAINT lad_user_id_fk FOREIGN KEY | ||
( | ||
user_id | ||
) | ||
REFERENCES users | ||
( | ||
user_id | ||
); | ||
|
||
ALTER TABLE log_audit_details | ||
ADD CONSTRAINT lad_log_action_id_fk FOREIGN KEY | ||
( | ||
log_action_id | ||
) | ||
REFERENCES log_actions | ||
( | ||
log_action_id | ||
); | ||
|
||
ALTER TABLE log_audit_details | ||
ADD CONSTRAINT lad_business_unit_id_fk FOREIGN KEY | ||
( | ||
business_unit_id | ||
) | ||
REFERENCES business_units | ||
( | ||
business_unit_id | ||
); | ||
|
||
COMMENT ON COLUMN log_audit_details.log_audit_detail_id IS 'Unique ID of this record'; | ||
COMMENT ON COLUMN log_audit_details.user_id IS 'The user whose actions led to the creation of this entry'; | ||
COMMENT ON COLUMN log_audit_details.log_timestamp IS 'System timestamp at the time of this entry'; | ||
COMMENT ON COLUMN log_audit_details.log_action_id IS 'The action that led to the creation of this entry'; | ||
COMMENT ON COLUMN log_audit_details.account_number IS 'The account related to this action if there is one'; | ||
COMMENT ON COLUMN log_audit_details.business_unit_id IS 'The business unit if there is one'; | ||
COMMENT ON COLUMN log_audit_details.json_request IS 'The REST request information received that initiated this action and written in a json format but stored as TEXT'; |
15 changes: 15 additions & 0 deletions
15
src/main/resources/db/migration/V20240320_100__log_audit_detail_id_seq .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,15 @@ | ||
/** | ||
* OPAL Program | ||
* | ||
* MODULE : log_audit_detail_id_seq.sql | ||
* | ||
* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table LOG_AUDIT_DETAILS. | ||
* | ||
* VERSION HISTORY: | ||
* | ||
* Date Author Version Nature of Change | ||
* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- | ||
* 20/03/2024 A Dennis 1.0 PO-227 Creates the Sequence to be used to generate the Primary key for the table LOG_AUDIT_DETAILS | ||
* | ||
**/ | ||
CREATE SEQUENCE IF NOT EXISTS log_audit_detail_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY log_audit_details.log_audit_detail_id; |
45 changes: 45 additions & 0 deletions
45
src/main/resources/db/migration/V20240320_101__configuration_items.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,45 @@ | ||
/** | ||
* CGI OPAL Program | ||
* | ||
* MODULE : configuration_items.sql | ||
* | ||
* DESCRIPTION : Creates the CONFIGURATION_ITEMS table for the Fines model | ||
* | ||
* VERSION HISTORY: | ||
* | ||
* Date Author Version Nature of Change | ||
* ---------- ------- -------- ---------------------------------------------------------------------------- | ||
* 20/03/2024 A Dennis 1.0 PO-227 Creates the CONFIGURATION_ITEMS table for the Fines model | ||
* | ||
**/ | ||
CREATE TABLE configuration_items | ||
( | ||
configuration_item_id bigint not null | ||
,item_name varchar(50) not null | ||
,business_unit_id smallint | ||
,item_value text | ||
,item_values varchar(500)[] | ||
,CONSTRAINT configuration_items_pk PRIMARY KEY | ||
( | ||
configuration_item_id | ||
) | ||
); | ||
|
||
ALTER TABLE configuration_items | ||
ADD CONSTRAINT ci_business_unit_id_fk FOREIGN KEY | ||
( | ||
business_unit_id | ||
) | ||
REFERENCES business_units | ||
( | ||
business_unit_id | ||
); | ||
|
||
CREATE INDEX IF NOT EXISTS ci_item_name_idx | ||
ON configuration_items(item_name); | ||
|
||
COMMENT ON COLUMN configuration_items.configuration_item_id IS 'Configuration item ID'; | ||
COMMENT ON COLUMN configuration_items.item_name IS 'Configuration item name'; | ||
COMMENT ON COLUMN configuration_items.business_unit_id IS 'ID of the business unit or NULL for all'; | ||
COMMENT ON COLUMN configuration_items.item_value IS 'Single text value'; | ||
COMMENT ON COLUMN configuration_items.item_values IS 'Multiple values'; |
15 changes: 15 additions & 0 deletions
15
src/main/resources/db/migration/V20240320_102__configuration_item_id_seq.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,15 @@ | ||
/** | ||
* OPAL Program | ||
* | ||
* MODULE : configuration_item_id_seq.sql | ||
* | ||
* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table CONFIGURATION_ITEMS. | ||
* | ||
* VERSION HISTORY: | ||
* | ||
* Date Author Version Nature of Change | ||
* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- | ||
* 20/03/2024 A Dennis 1.0 PO-227 Creates the Sequence to be used to generate the Primary key for the table CONFIGURATION_ITEMS | ||
* | ||
**/ | ||
CREATE SEQUENCE IF NOT EXISTS configuration_item_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY configuration_items.configuration_item_id; |
81 changes: 81 additions & 0 deletions
81
src/main/resources/db/migration/V20240320_103__insert_configuration_items.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,81 @@ | ||
/** | ||
* OPAL Program | ||
* | ||
* MODULE : insert_configuration_items.sql | ||
* | ||
* DESCRIPTION : Inserts rows of data into the CONFIGURATION_ITEMS table. | ||
* | ||
* VERSION HISTORY: | ||
* | ||
* Date Author Version Nature of Change | ||
* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- | ||
* 20/03/2024 A Dennis 1.0 PO-227 Inserts rows of data into the CONFIGURATION_ITEMS table | ||
* | ||
**/ | ||
INSERT INTO configuration_items | ||
( | ||
configuration_item_id | ||
,item_name | ||
,business_unit_id | ||
,item_value | ||
,item_values | ||
) | ||
VALUES | ||
( | ||
500000000 | ||
,'AUDIT_LOG_RETENTION_PERIOD_DAYS' | ||
,null | ||
,'100' | ||
,NULL | ||
); | ||
|
||
INSERT INTO configuration_items | ||
( | ||
configuration_item_id | ||
,item_name | ||
,business_unit_id | ||
,item_value | ||
,item_values | ||
) | ||
VALUES | ||
( | ||
500000001 | ||
,'COURT_TYPES' | ||
,null | ||
,null | ||
,ARRAY['Magistrate', 'Crown', 'Appeal', 'High','Supreme'] | ||
); | ||
|
||
INSERT INTO configuration_items | ||
( | ||
configuration_item_id | ||
,item_name | ||
,business_unit_id | ||
,item_value | ||
,item_values | ||
) | ||
VALUES | ||
( | ||
500000002 | ||
,'RATE_TYPES' | ||
,73 | ||
,null | ||
,'{"Business", "Local", "County", "Emergency", "Voluntary"}' | ||
); | ||
|
||
INSERT INTO configuration_items | ||
( | ||
configuration_item_id | ||
,item_name | ||
,business_unit_id | ||
,item_value | ||
,item_values | ||
) | ||
VALUES | ||
( | ||
500000003 | ||
,'RATE_TYPES' | ||
,24 | ||
,null | ||
,'{"Community", "Welfare", "Business", "Local", "County", "Emergency", "Voluntary"}' | ||
); |
57 changes: 57 additions & 0 deletions
57
src/main/resources/db/migration/V20240320_104__insert_log_actions.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,57 @@ | ||
/** | ||
* OPAL Program | ||
* | ||
* MODULE : insert_log_actions.sql | ||
* | ||
* DESCRIPTION : Inserts rows of data into the LOG_ACTIONS table. | ||
* | ||
* VERSION HISTORY: | ||
* | ||
* Date Author Version Nature of Change | ||
* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- | ||
* 20/03/2024 A Dennis 1.0 PO-227 Inserts rows of data into the LOG_ACTIONS table | ||
* | ||
**/ | ||
INSERT INTO log_actions | ||
( | ||
log_action_id | ||
,log_action_name | ||
) | ||
VALUES | ||
( | ||
5000 | ||
,'Log In' | ||
); | ||
|
||
INSERT INTO log_actions | ||
( | ||
log_action_id | ||
,log_action_name | ||
) | ||
VALUES | ||
( | ||
5001 | ||
,'Log Out' | ||
); | ||
|
||
INSERT INTO log_actions | ||
( | ||
log_action_id | ||
,log_action_name | ||
) | ||
VALUES | ||
( | ||
5002 | ||
,'Account Notes' | ||
); | ||
|
||
INSERT INTO log_actions | ||
( | ||
log_action_id | ||
,log_action_name | ||
) | ||
VALUES | ||
( | ||
5004 | ||
,'Account Enquiry - Account Notes' | ||
); |
15 changes: 15 additions & 0 deletions
15
src/main/resources/db/migration/V20240320_105__user_id_seq.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,15 @@ | ||
/** | ||
* OPAL Program | ||
* | ||
* MODULE : user_id_seq.sql | ||
* | ||
* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table USERS. | ||
* | ||
* VERSION HISTORY: | ||
* | ||
* Date Author Version Nature of Change | ||
* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- | ||
* 20/03/2024 A Dennis 1.0 PO-227 Creates the Sequence to be used to generate the Primary key for the table USERS | ||
* | ||
**/ | ||
CREATE SEQUENCE IF NOT EXISTS user_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY users.user_id; |