Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data model 72.5 #2558

Merged
merged 4 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified src/main/resources/db/reference/modernised_darts_erd.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
-- v9 add 2 event and 2 media indexes
-- v10 amend index on user_account from user_name to user_full_name
-- v11 add numerous indexes to accommodate all FKs
-- v12 add index on media for chronicle_id

SET ROLE DARTS_OWNER;
SET SEARCH_PATH TO darts;
Expand Down Expand Up @@ -310,5 +311,5 @@ CREATE INDEX cas_cn_trgm_idx ON court_case USING gin (case_number gin_trgm_ops);

CREATE INDEX ctr_cn_trgm_idx ON courtroom USING gin (courtroom_name gin_trgm_ops);



-- v12
CREATE INDEX med_chronicle_id_idx ON media (chronicle_id);
6 changes: 6 additions & 0 deletions src/main/resources/db/reference/modernised_darts_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@
-- remove folder_path from event,media & transcription
-- add production_name to arm_rpo_execution_detail
-- add is_dets to external_object_directory
--v72.5 add storage_id to media, transcription_document, daily_list,annotation_document, object_retrieval_queue

-- List of Table Aliases
-- annotation ANN
Expand Down Expand Up @@ -479,6 +480,7 @@ CREATE TABLE annotation_document
,subcontent_object_id CHARACTER VARYING(16)
,subcontent_position INTEGER
,clip_id CHARACTER VARYING(54)
,storage_id CHARACTER VARYING(16)
,data_ticket INTEGER
,file_name CHARACTER VARYING NOT NULL
,file_type CHARACTER VARYING NOT NULL
Expand Down Expand Up @@ -846,6 +848,7 @@ CREATE TABLE daily_list
,subcontent_object_id CHARACTER VARYING(16)
,subcontent_position INTEGER
,clip_id CHARACTER VARYING
,storage_id CHARACTER VARYING(16)
,data_ticket INTEGER
,external_location UUID
,elt_id INTEGER
Expand Down Expand Up @@ -1224,6 +1227,7 @@ CREATE TABLE media
,subcontent_object_id CHARACTER VARYING(16)
,subcontent_position INTEGER
,clip_id CHARACTER VARYING(54)
,storage_id CHARACTER VARYING(16)
,data_ticket INTEGER
,channel INTEGER NOT NULL -- 1,2,3,4 or rarely 5
,total_channels INTEGER NOT NULL --99.9% are "4" in legacy, occasionally 1,2,5
Expand Down Expand Up @@ -1426,6 +1430,7 @@ CREATE TABLE object_retrieval_queue
,trd_id INTEGER
,parent_object_id CHARACTER VARYING
,content_object_id CHARACTER VARYING
,storage_id CHARACTER VARYING(16)
,clip_id CHARACTER VARYING
,data_ticket INTEGER
,acknowledged_ts TIMESTAMP WITH TIME ZONE
Expand Down Expand Up @@ -1594,6 +1599,7 @@ CREATE TABLE transcription_document
,subcontent_object_id CHARACTER VARYING(16)
,subcontent_position INTEGER
,clip_id CHARACTER VARYING(54)
,storage_id CHARACTER VARYING(16)
,data_ticket INTEGER
,file_name CHARACTER VARYING NOT NULL
,file_type CHARACTER VARYING NOT NULL
Expand Down
41 changes: 29 additions & 12 deletions src/main/resources/db/reference/object_state_record.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@
--v5 amend tablespace to pg_default
--v6 add revinfo table, as another externally defined object
--v7 add audit_user to revinfo and FK to user_account
--v8 add storage_id and data_ticket to object_state_record
-- add primary key to object_state_record
-- add various indexes to object_state_record
-- remove id_case,courthouse_name,date_last_accessed,flag_file_retained_in_ods from object_state_record
-- remove relation_id,cas_id,parent_id,object_type from object_state_record


CREATE TABLE object_state_record
(osr_uuid BIGINT NOT NULL
,eod_id CHARACTER VARYING
,arm_eod_id CHARACTER VARYING
,parent_id CHARACTER VARYING --
,parent_object_id CHARACTER VARYING --
,content_object_id CHARACTER VARYING --
,object_type CHARACTER VARYING --
,parent_object_id CHARACTER VARYING
,content_object_id CHARACTER VARYING
,id_clip CHARACTER VARYING
,id_case CHARACTER VARYING
,courthouse_name CHARACTER VARYING
,cas_id INTEGER
,date_last_accessed TIMESTAMP WITH TIME ZONE
,relation_id CHARACTER VARYING
,dets_location CHARACTER VARYING --
,dets_location CHARACTER VARYING
,flag_file_transfer_to_dets BOOLEAN
,date_file_transfer_to_dets TIMESTAMP WITH TIME ZONE
,md5_doc_transfer_to_dets CHARACTER VARYING
Expand Down Expand Up @@ -49,10 +47,29 @@ CREATE TABLE object_state_record
,id_response_uf_file CHARACTER VARYING
,flag_file_dets_cleanup_status BOOLEAN
,date_file_dets_cleanup TIMESTAMP WITH TIME ZONE
,flag_file_retained_in_ods BOOLEAN
,object_status CHARACTER VARYING
,storage_id CHARACTER VARYING
,data_ticket INTEGER
) TABLESPACE pg_default;

CREATE UNIQUE INDEX object_state_record_pk ON object_state_record(osr_uuid) TABLESPACE pg_default;
ALTER TABLE object_state_record ADD PRIMARY KEY USING INDEX object_state_record_pk;

-- multicolumn index, as two columns will be referenced together
CREATE INDEX osr_storage_id_data_ticket ON object_state_record(storage_id,data_ticket) TABLESPACE pg_default;

-- only one of the following two indexes should be retained
CREATE INDEX osr_id_clip ON object_state_record(id_clip) TABLESPACE pg_default;
-- if the queries that neccesitate this index remain, remove single column, otherwise retain this one,and remove id_clip.
CREATE INDEX osr_id_clip_md5_doc_tx_dets ON object_state_record(id_clip,md5_doc_transfer_to_dets) TABLESPACE pg_default;

-- obviously if the md5 column is not needed in the 2 column index above, the following would also be redundant
CREATE INDEX osr_md5_doc_tx_dets ON object_state_record(md5_doc_transfer_to_dets) TABLESPACE pg_default;

CREATE INDEX osr_content_object_id ON object_state_record(content_object_id) TABLESPACE pg_default;
CREATE INDEX osr_flag_file_transfer_to_dets ON object_state_record(flag_file_transfer_to_dets) TABLESPACE pg_default;


CREATE TABLE revinfo
(rev INT4 NOT NULL
,revtstmp INT8
Expand All @@ -62,4 +79,4 @@ CREATE TABLE revinfo

ALTER TABLE revinfo
ADD CONSTRAINT revinfo_audit_user_fk
FOREIGN KEY (audit_user) REFERENCES user_account(usr_id);
FOREIGN KEY (audit_user) REFERENCES user_account(usr_id);
40 changes: 9 additions & 31 deletions src/main/resources/db/reference/retention.sql
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
-- v17 replace definition of case_retention_extra
-- add pk to retention_policy_type_heritage_mapping
-- amend manual_retention_override and actual_case_closed_flag to int from bool
--v18 add default to created_ts on case_overflow
-- drop cas_id
-- add case_object_id and audio_folder_object_id

SET ROLE DARTS_OWNER;
SET SEARCH_PATH TO darts;
Expand All @@ -67,11 +70,12 @@ CREATE TABLE case_management_retention

CREATE TABLE rps_retainer
(rpr_id INTEGER NOT NULL
,cas_id INTEGER
,rpt_id INTEGER NOT NULL
,rps_retainer_object_id CHARACTER VARYING NOT NULL -- all data will be from legacy
,is_current BOOLEAN
,dm_retainer_root_id CHARACTER VARYING
,is_current BOOLEAN
,case_object_id CHARACTER VARYING
,audio_folder_object_id CHARACTER VARYING
,dm_retainer_root_id CHARACTER VARYING
,dm_retention_rule_type INTEGER
,dm_retention_date TIMESTAMP WITH TIME ZONE -- retaining _date to indictate source
,dmc_current_phase_id CHARACTER VARYING
Expand Down Expand Up @@ -109,8 +113,6 @@ COMMENT ON TABLE rps_retainer
IS 'is essentially a legacy table, based on the component tables necessary to derive the dmc_rps_retainer object';
COMMENT ON COLUMN rps_retainer.rpr_id
IS 'primary key of case_rps_retainer';
COMMENT ON COLUMN rps_retainer.cas_id
IS 'foreign key to court_case';

CREATE TABLE case_retention
(car_id INTEGER NOT NULL
Expand Down Expand Up @@ -194,33 +196,13 @@ CREATE TABLE case_overflow
,end_of_sentence_date_ts TIMESTAMP WITH TIME ZONE
,manual_retention_override INTEGER
,retain_until_ts TIMESTAMP WITH TIME ZONE
--,is_standard_policy BOOLEAN
--,is_permanent_policy BOOLEAN
--,checked_ts TIMESTAMP WITH TIME ZONE
--,corrected_ts TIMESTAMP WITH TIME ZONE
,c_closed_pre_live INTEGER
,c_case_closed_date_pre_live TIMESTAMP WITH TIME ZONE
,case_created_ts TIMESTAMP WITH TIME ZONE
,audio_folder_object_id CHARACTER VARYING(16)
--,case_object_name CHARACTER VARYING(255) -- to accommodate dm_sysobject_s.object_name
--,case_closed_eve_id INTEGER -- unenforced fk to event
--,tol_case_closed_ts TIMESTAMP WITH TIME ZONE
--,tol_case_closed_type CHARACTER VARYING -- enumerated type, not normalised
--,ret_retain_until_ts TIMESTAMP WITH TIME ZONE
--,aud_retain_until_ts TIMESTAMP WITH TIME ZONE
--,migration_type CHARACTER VARYING -- to indicate how we've got to this point with this record
--,migration_error_1 CHARACTER VARYING
--,migration_error_2 CHARACTER VARYING
--,migration_error_3 CHARACTER VARYING
--,migration_error_4 CHARACTER VARYING
--,ret_conf_score INTEGER
--,ret_conf_reason CHARACTER VARYING
--,ret_conf_updated_ts TIMESTAMP WITH TIME ZONE
--,tol_diff_c_close_in_days INTEGER
--,tol_diff_ret_dt_in_days INTEGER
,case_last_modified_ts TIMESTAMP WITH TIME ZONE -- to support delta, when case changed
,audio_last_modified_ts TIMESTAMP WITH TIME ZONE -- to suppor delta, when moj_audio_folder changes
,created_ts TIMESTAMP WITH TIME ZONE NOT NULL
,created_ts TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT current_timestamp
,last_modified_ts TIMESTAMP WITH TIME ZONE NOT NULL
) TABLESPACE pg_default;

Expand Down Expand Up @@ -312,11 +294,7 @@ CREATE SEQUENCE rpt_seq CACHE 20;
CREATE SEQUENCE rah_seq CACHE 20;
CREATE SEQUENCE rhm_seq CACHE 20;

ALTER TABLE rps_retainer
ADD CONSTRAINT rps_retainer_court_case_fk
FOREIGN KEY (cas_id) REFERENCES court_case(cas_id);

ALTER TABLE rps_retainer
ALTER TABLE rps_retainer
ADD CONSTRAINT rps_retainer_retention_policy_type_fk
FOREIGN KEY (rpt_id) REFERENCES retention_policy_type(rpt_id);

Expand Down