Skip to content

Commit

Permalink
PO-305 added the reference data load for local justice areas.
Browse files Browse the repository at this point in the history
  • Loading branch information
abrahamdennis authored and RustyHMCTS committed May 7, 2024
1 parent c08be18 commit 1a489de
Show file tree
Hide file tree
Showing 7 changed files with 307 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* OPAL Program
*
* MODULE : modify_local_justice_areas.sql
*
* DESCRIPTION : Modify the LOCAL_JUSTICE_AREAS table in order to be able to load Reference Data from data held in Excel spreadsheet.
*
* VERSION HISTORY:
*
* Date Author Version Nature of Change
* ---------- ------- -------- ---------------------------------------------------------------------------------------------------------------------------
* 05/05/2024 A Dennis 1.0 PO-305 Modify the LOCAL_JUSTICE_AREAS table in order to be able to load Reference Data from data held in Excel spreadsheet.
*
**/
ALTER TABLE local_justice_areas
ADD COLUMN lja_code varchar(4),
ADD COLUMN address_line_4 varchar(35),
ADD COLUMN address_line_5 varchar(35),
ADD COLUMN end_date timestamp;

COMMENT ON COLUMN local_justice_areas.lja_code IS 'LJA Code';
COMMENT ON COLUMN local_justice_areas.address_line_4 IS 'LJA Address line 4';
COMMENT ON COLUMN local_justice_areas.address_line_5 IS 'LJA Address line 5';
COMMENT ON COLUMN local_justice_areas.end_date IS 'The end date of the record';

ALTER TABLE local_justice_areas
ALTER COLUMN name TYPE varchar(100);

ALTER TABLE account_transfers
DROP constraint IF EXISTS at_local_justice_area_id_fk;

ALTER TABLE defendant_accounts
DROP constraint IF EXISTS res_enf_override_tfo_lja_id_fk;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* OPAL Program
*
* MODULE : modify_local_justice_areas.sql
*
* DESCRIPTION : Truncate the LOCAL_JUSTICE_AREAS table in order to be able to load Reference Data from data held in Excel spreadsheet.
*
* VERSION HISTORY:
*
* Date Author Version Nature of Change
* ---------- ------- -------- ---------------------------------------------------------------------------------------------------------------------------
* 05/05/2024 A Dennis 1.0 PO-305 Truncate the LOCAL_JUSTICE_AREAS table in order to be able to load Reference Data from data held in Excel spreadsheet.
*
**/

TRUNCATE TABLE local_justice_areas;

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* OPAL Program
*
* MODULE : update_account_transfers.sql
*
* DESCRIPTION : Update rows of test data in the ACCOUNT_TRANSFERS table after the Local Justice Areas reference data load from spreadsheets to match them to new parent data.
*
* VERSION HISTORY:
*
* Date Author Version Nature of Change
* ---------- ------- -------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------
* 05/05/2024 A Dennis 1.0 PO-305 Update rows of test data in the ACCOUNT_TRANSFERS table after the Local Justice Areas reference data load from spreadsheets to match them to new parent data.
**/
UPDATE account_transfers
SET destination_lja_id = 1814
WHERE destination_lja_id = 2022;

UPDATE account_transfers
SET destination_lja_id = 2052
WHERE destination_lja_id = 2216;

UPDATE account_transfers
SET destination_lja_id = 2126
WHERE destination_lja_id = 2232;

UPDATE account_transfers
SET destination_lja_id = 2530
WHERE destination_lja_id = 2651;

UPDATE account_transfers
SET destination_lja_id = 2540
WHERE destination_lja_id = 2078;

UPDATE account_transfers
SET destination_lja_id = 2619
WHERE destination_lja_id = 1755;

UPDATE account_transfers
SET destination_lja_id = 3098
WHERE destination_lja_id = 2320;

UPDATE account_transfers
SET destination_lja_id = 3119
WHERE destination_lja_id = 2160;

UPDATE account_transfers
SET destination_lja_id = 3123
WHERE destination_lja_id = 3119;

UPDATE account_transfers
SET destination_lja_id = 3190
WHERE destination_lja_id = 2831;
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* OPAL Program
*
* MODULE : update_account_transfers.sql
*
* DESCRIPTION : Update rows of test data in the DEFENDANT_ACCOUNTS table after the Local Justice Areas reference data load from spreadsheets to match them to new parent data.
*
* VERSION HISTORY:
*
* Date Author Version Nature of Change
* ---------- ------- -------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------
* 05/05/2024 A Dennis 1.0 PO-305 Update rows of test data in the DEFENDANT_ACCOUNTS table after the Local Justice Areas reference data load from spreadsheets to match them to new parent data.
**/
UPDATE defendant_accounts
SET enf_override_tfo_lja_id = 1814
WHERE enf_override_tfo_lja_id = 2022;

UPDATE defendant_accounts
SET enf_override_tfo_lja_id = 2052
WHERE enf_override_tfo_lja_id = 2216;

UPDATE defendant_accounts
SET enf_override_tfo_lja_id = 2126
WHERE enf_override_tfo_lja_id = 2232;

UPDATE defendant_accounts
SET enf_override_tfo_lja_id = 2530
WHERE enf_override_tfo_lja_id = 2651;

UPDATE defendant_accounts
SET enf_override_tfo_lja_id = 2540
WHERE enf_override_tfo_lja_id = 2078;

UPDATE defendant_accounts
SET enf_override_tfo_lja_id = 2619
WHERE enf_override_tfo_lja_id = 1755;

UPDATE defendant_accounts
SET enf_override_tfo_lja_id = 3098
WHERE enf_override_tfo_lja_id = 2320;

UPDATE defendant_accounts
SET enf_override_tfo_lja_id = 3119
WHERE enf_override_tfo_lja_id = 2160;

UPDATE defendant_accounts
SET enf_override_tfo_lja_id = 3123
WHERE enf_override_tfo_lja_id = 3119;

UPDATE defendant_accounts
SET enf_override_tfo_lja_id = 3190
WHERE enf_override_tfo_lja_id = 2831;
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* CGI OPAL Program
*
* MODULE : enable_tables_lja_fks.sql
*
* DESCRIPTION : Enable local justice areas foreign keys in tables that had them dropped in order to load LJA reference data for the Fines model
*
* VERSION HISTORY:
*
* Date Author Version Nature of Change
* ---------- ------- -------- --------------------------------------------------------------------------------------------------------------------------------------
* 05/05/2024 A Dennis 1.0 PO-305 Enable local justice areas foreign keys in tables that had them dropped in order to load LJA reference data for the Fines model
*
**/

ALTER TABLE account_transfers
ADD CONSTRAINT at_destination_lja_id_fk FOREIGN KEY
(
destination_lja_id
)
REFERENCES local_justice_areas
(
local_justice_area_id
);

ALTER TABLE defendant_accounts
ADD CONSTRAINT da_enf_override_tfo_lja_id_fk FOREIGN KEY
(
enf_override_tfo_lja_id
)
REFERENCES local_justice_areas
(
local_justice_area_id
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* OPAL Program
*
* MODULE : modify_tables_columns_1.sql
*
* DESCRIPTION : The columns in this script are being modified due to typos in the data model spreadsheet for the Fines model. Included under this Jira ticket for ease.
*
* VERSION HISTORY:
*
* Date Author Version Nature of Change
* ---------- ------- -------- --------------------------------------------------------------------------------------------------------------------------------------------------------------
* 07/05/2024 A Dennis 1.0 PO-305 The columns in this script are being modified due to typos in the data model spreadsheet for the Fines model. Included under this Jira ticket for ease.
*
**/

ALTER TABLE enforcements
ALTER COLUMN result_id TYPE varchar(6);

ALTER TABLE impositions
ALTER COLUMN posted_by_user_id DROP NOT NULL;

ALTER TABLE creditor_transactions
ALTER COLUMN posted_by_user_id DROP NOT NULL;

ALTER TABLE suspense_transactions
ALTER COLUMN posted_by_user_id DROP NOT NULL;

0 comments on commit 1a489de

Please sign in to comment.