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-177, 186 and 195 to create users related tables and alter existing…
… tables
- Loading branch information
1 parent
cea34e7
commit 61244ea
Showing
11 changed files
with
322 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* CGI OPAL Program | ||
* | ||
* MODULE : users.sql | ||
* | ||
* DESCRIPTION : Creates the USERS table for the Fines model | ||
* | ||
* VERSION HISTORY: | ||
* | ||
* Date Author Version Nature of Change | ||
* ---------- ------- -------- ---------------------------------------------------------------------------- | ||
* 11/02/2024 A Dennis 1.0 PO-177 Creates the USERS table for the Fines model | ||
* | ||
**/ | ||
CREATE TABLE users | ||
( | ||
user_id varchar(100) not null | ||
,username varchar(100) not null | ||
,password varchar(1000) | ||
,description varchar(100) | ||
,CONSTRAINT users_pk PRIMARY KEY | ||
( | ||
user_id | ||
) | ||
); | ||
|
||
COMMENT ON COLUMN users.user_id IS 'Unique ID of this record'; | ||
COMMENT ON COLUMN users.username IS 'User name/email based on Azure Active Directory ID'; | ||
COMMENT ON COLUMN users.username IS 'Password'; | ||
COMMENT ON COLUMN users.description IS 'Description of the user'; |
48 changes: 48 additions & 0 deletions
48
src/main/resources/db/migration/V20240210_073__business_unit_users.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,48 @@ | ||
/** | ||
* CGI OPAL Program | ||
* | ||
* MODULE : business_unit_users.sql | ||
* | ||
* DESCRIPTION : Creates the BUSINESS UNIT USERS table for the Fines model | ||
* | ||
* VERSION HISTORY: | ||
* | ||
* Date Author Version Nature of Change | ||
* ---------- ------- -------- ---------------------------------------------------------------------------- | ||
* 11/02/2024 A Dennis 1.0 PO-177 Creates the BUSINESS UNIT USERS table for the Fines model | ||
* | ||
**/ | ||
CREATE TABLE business_unit_users | ||
( | ||
business_unit_user_id varchar(6) not null | ||
,business_unit_id smallint not null | ||
,user_id varchar(100) not null | ||
,CONSTRAINT business_unit_users_pk PRIMARY KEY | ||
( | ||
business_unit_user_id | ||
) | ||
); | ||
|
||
ALTER TABLE business_unit_users | ||
ADD CONSTRAINT buu_business_unit_id_fk FOREIGN KEY | ||
( | ||
business_unit_id | ||
) | ||
REFERENCES business_units | ||
( | ||
business_unit_id | ||
); | ||
|
||
ALTER TABLE business_unit_users | ||
ADD CONSTRAINT buu_user_id_fk FOREIGN KEY | ||
( | ||
user_id | ||
) | ||
REFERENCES users | ||
( | ||
user_id | ||
); | ||
|
||
COMMENT ON COLUMN business_unit_users.business_unit_user_id IS 'Unique ID of this record'; | ||
COMMENT ON COLUMN business_unit_users.business_unit_id IS 'ID of the business unit the user belongs to'; | ||
COMMENT ON COLUMN business_unit_users.user_id IS 'The user ID, based on AAD, and is the foreign key to the Users table'; |
26 changes: 26 additions & 0 deletions
26
src/main/resources/db/migration/V20240210_074__application_functions.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 : application_functions.sql | ||
* | ||
* DESCRIPTION : Creates the APPLICATION FUNCTIONS table for the Fines model | ||
* | ||
* VERSION HISTORY: | ||
* | ||
* Date Author Version Nature of Change | ||
* ---------- ------- -------- ---------------------------------------------------------------------------- | ||
* 11/02/2024 A Dennis 1.0 PO-177 Creates the APPLICATION FUNCTIONS table for the Fines model | ||
* | ||
**/ | ||
CREATE TABLE application_functions | ||
( | ||
application_function_id bigint not null | ||
,function_name varchar(200) not null | ||
,CONSTRAINT application_functions_pk PRIMARY KEY | ||
( | ||
application_function_id | ||
) | ||
); | ||
|
||
COMMENT ON COLUMN application_functions.application_function_id IS 'Unique ID of this record'; | ||
COMMENT ON COLUMN application_functions.function_name IS 'Function name'; |
15 changes: 15 additions & 0 deletions
15
src/main/resources/db/migration/V20240210_075__application_function_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 : application_function_id_seq.sql | ||
* | ||
* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table APPLICATION FUNCTIONS UNIT ROLES. | ||
* | ||
* VERSION HISTORY: | ||
* | ||
* Date Author Version Nature of Change | ||
* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- | ||
* 10/02/2024 A Dennis 1.0 PO-177 Creates the Sequence to be used to generate the Primary key for the table APPLICATION FUNCTIONS | ||
* | ||
**/ | ||
CREATE SEQUENCE IF NOT EXISTS application_function_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY application_functions.application_function_id; |
48 changes: 48 additions & 0 deletions
48
src/main/resources/db/migration/V20240210_076__user_entitlements.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,48 @@ | ||
/** | ||
* CGI OPAL Program | ||
* | ||
* MODULE : user_entitlements.sql | ||
* | ||
* DESCRIPTION : Creates the USER ENTITLEMENTS table for the Fines model | ||
* | ||
* VERSION HISTORY: | ||
* | ||
* Date Author Version Nature of Change | ||
* ---------- ------- -------- ---------------------------------------------------------------------------- | ||
* 11/02/2024 A Dennis 1.0 PO-177 Creates the USER ENTITLEMENTS table for the Fines model | ||
* | ||
**/ | ||
CREATE TABLE user_entitlements | ||
( | ||
user_entitlement_id bigint not null | ||
,business_unit_user_id varchar(6) not null | ||
,application_function_id bigint not null | ||
,CONSTRAINT user_entitlements_pk PRIMARY KEY | ||
( | ||
user_entitlement_id | ||
) | ||
); | ||
|
||
ALTER TABLE user_entitlements | ||
ADD CONSTRAINT ue_business_unit_user_id_fk FOREIGN KEY | ||
( | ||
business_unit_user_id | ||
) | ||
REFERENCES business_unit_users | ||
( | ||
business_unit_user_id | ||
); | ||
|
||
ALTER TABLE user_entitlements | ||
ADD CONSTRAINT ue_application_function_id_fk FOREIGN KEY | ||
( | ||
application_function_id | ||
) | ||
REFERENCES application_functions | ||
( | ||
application_function_id | ||
); | ||
|
||
COMMENT ON COLUMN user_entitlements.user_entitlement_id IS 'Unique ID of this record'; | ||
COMMENT ON COLUMN user_entitlements.business_unit_user_id IS 'ID of the business unit user this record is for'; | ||
COMMENT ON COLUMN user_entitlements.application_function_id IS 'ID of the application function the business unit user can access'; |
15 changes: 15 additions & 0 deletions
15
src/main/resources/db/migration/V20240210_077__user_entitlement_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_entitlement_id_seq.sql | ||
* | ||
* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table USER_ENTITLEMENTS. | ||
* | ||
* VERSION HISTORY: | ||
* | ||
* Date Author Version Nature of Change | ||
* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- | ||
* 11/02/2024 A Dennis 1.0 PO-177 Creates the Sequence to be used to generate the Primary key for the table USER_ENTITLEMENTS | ||
* | ||
**/ | ||
CREATE SEQUENCE IF NOT EXISTS user_entitlement_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY user_entitlements.user_entitlement_id; |
26 changes: 26 additions & 0 deletions
26
src/main/resources/db/migration/V20240213_078__templates.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 : templates.sql | ||
* | ||
* DESCRIPTION : Creates the TEMPLATES table for the Fines model | ||
* | ||
* VERSION HISTORY: | ||
* | ||
* Date Author Version Nature of Change | ||
* ---------- ------- -------- ---------------------------------------------------------------------------- | ||
* 13/02/2024 A Dennis 1.0 PO-177 Creates the TEMPLATES table for the Fines model | ||
* | ||
**/ | ||
CREATE TABLE templates | ||
( | ||
template_id bigint not null | ||
,template_name varchar(100) | ||
,CONSTRAINT templates_pk PRIMARY KEY | ||
( | ||
template_id | ||
) | ||
); | ||
|
||
COMMENT ON COLUMN templates.template_id IS 'Unique ID of this record'; | ||
COMMENT ON COLUMN templates.template_name IS 'The template name or description'; |
15 changes: 15 additions & 0 deletions
15
src/main/resources/db/migration/V20240213_079__template_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 : template_id_seq.sql | ||
* | ||
* DESCRIPTION : Creates the Sequence to be used to generate the Primary key for the table TEMPLATES. | ||
* | ||
* VERSION HISTORY: | ||
* | ||
* Date Author Version Nature of Change | ||
* ---------- ------- -------- --------------------------------------------------------------------------------------------------------- | ||
* 13/02/2024 A Dennis 1.0 PO-177 Creates the Sequence to be used to generate the Primary key for the table TEMPLATES | ||
* | ||
**/ | ||
CREATE SEQUENCE IF NOT EXISTS template_id_seq INCREMENT 1 MINVALUE 1 NO MAXVALUE START WITH 1 CACHE 20 OWNED BY templates.template_id; |
46 changes: 46 additions & 0 deletions
46
src/main/resources/db/migration/V20240213_080__template_mappings.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 @@ | ||
/** | ||
* CGI OPAL Program | ||
* | ||
* MODULE : template_mappings.sql | ||
* | ||
* DESCRIPTION : Creates the TEMPLATE_MAPPINGSS table for the Fines model | ||
* | ||
* VERSION HISTORY: | ||
* | ||
* Date Author Version Nature of Change | ||
* ---------- ------- -------- ---------------------------------------------------------------------------- | ||
* 13/02/2024 A Dennis 1.0 PO-177 Creates the TEMPLATE_MAPPINGS table for the Fines model | ||
* | ||
**/ | ||
CREATE TABLE template_mappings | ||
( | ||
template_id bigint not null | ||
,application_function_id bigint not null | ||
,CONSTRAINT template_mappings_pk PRIMARY KEY | ||
( | ||
template_id, application_function_id | ||
) | ||
); | ||
|
||
ALTER TABLE template_mappings | ||
ADD CONSTRAINT tm_template_id_fk FOREIGN KEY | ||
( | ||
template_id | ||
) | ||
REFERENCES templates | ||
( | ||
template_id | ||
); | ||
|
||
ALTER TABLE template_mappings | ||
ADD CONSTRAINT tm_application_function_id_fk FOREIGN KEY | ||
( | ||
application_function_id | ||
) | ||
REFERENCES application_functions | ||
( | ||
application_function_id | ||
); | ||
|
||
COMMENT ON COLUMN template_mappings.template_id IS 'ID of the template'; | ||
COMMENT ON COLUMN template_mappings.application_function_id IS 'ID of the application function'; |
27 changes: 27 additions & 0 deletions
27
src/main/resources/db/migration/V20240213_081__notes_add_column.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,27 @@ | ||
/** | ||
* CGI OPAL Program | ||
* | ||
* MODULE : notes_add_column.sql | ||
* | ||
* DESCRIPTION : Add posted_by_aad column to NOTES table for the Fines model | ||
* | ||
* VERSION HISTORY: | ||
* | ||
* Date Author Version Nature of Change | ||
* ---------- ------- -------- ---------------------------------------------------------------------------- | ||
* 13/02/2024 A Dennis 1.0 PO-186 Add posted_by_aad column to NOTES table for the Fines model | ||
* | ||
**/ | ||
|
||
ALTER TABLE notes | ||
ADD COLUMN posted_by_aad varchar(100); | ||
|
||
ALTER TABLE notes | ||
ADD CONSTRAINT notes_posted_by_aad_fk FOREIGN KEY | ||
( | ||
posted_by_aad | ||
) | ||
REFERENCES users | ||
( | ||
user_id | ||
); |
26 changes: 26 additions & 0 deletions
26
src/main/resources/db/migration/V20240213_082__modify_document_instance.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 : modify_document_instance.sql | ||
* | ||
* DESCRIPTION : Change document_instances.document_id from BIGINT varchar(10) to match what is in the DOCUMENTS table for the Fines model | ||
* | ||
* VERSION HISTORY: | ||
* | ||
* Date Author Version Nature of Change | ||
* ---------- ------- -------- ------------------------------------------------------------------------------------------------------------- | ||
* 13/02/2024 A Dennis 1.0 PO-195 Change document_instances.document_id from BIGINT varchar(10) to match what is in the DOCUMENTS table for the Fines model | ||
* | ||
**/ | ||
ALTER TABLE document_instances | ||
ALTER COLUMN document_id TYPE VARCHAR(10); | ||
|
||
ALTER TABLE document_instances | ||
ADD CONSTRAINT di_document_id_fk FOREIGN KEY | ||
( | ||
document_id | ||
) | ||
REFERENCES documents | ||
( | ||
document_id | ||
); |