-
Notifications
You must be signed in to change notification settings - Fork 1
LEGLINK-789: Speed up Validation service result persistence #1822
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
734a8c0
Add review and submit properties to validation categories. Update UI …
johnbritton b4035a5
Update Web/Admin.UI/src/app/components/validation-config/validation-c…
johnbritton 6e88c17
Use DB sequence for Result IDs
johnbritton 04f8f55
Merge branch 'dev' into users/jbritton/LEGLINK-789
johnbritton cfc0fcc
Remove schema from SequenceGenerator in Result
johnbritton 24864cb
Merge branch 'dev' into users/jbritton/LEGLINK-789
johnbritton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
112 changes: 112 additions & 0 deletions
112
...tion/src/main/resources/database/migrations/V20260812__result_sequence_recreate_table.sql
This file contains hidden or 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,112 @@ | ||
| -- Drop old result tables (data will be lost per migration plan) | ||
| if exists (select 1 from sys.foreign_keys where name = 'fk_result_category_result_id') | ||
| begin | ||
| alter table result_category drop constraint fk_result_category_result_id | ||
| end | ||
|
|
||
| if exists (select 1 from sys.foreign_keys where name = 'fk_result_category_category_id') | ||
| begin | ||
| alter table result_category drop constraint fk_result_category_category_id | ||
| end | ||
|
|
||
| if exists (select 1 from sys.tables where name = 'result_category' and schema_id = schema_id('dbo')) | ||
| begin | ||
| drop table result_category | ||
| end | ||
|
|
||
| if exists (select 1 from sys.tables where name = 'result' and schema_id = schema_id('dbo')) | ||
| begin | ||
| drop table result | ||
| end | ||
|
|
||
| if exists (select 1 from sys.sequences where name = 'result_sequence' and schema_name(schema_id) = 'dbo') | ||
| begin | ||
| drop sequence dbo.result_sequence | ||
| end | ||
|
|
||
| -- Create sequence for Result IDs | ||
| create sequence dbo.result_sequence | ||
| as bigint | ||
| start with 1 | ||
| increment by 100; | ||
|
|
||
| -- Recreate result table using sequence-based IDs (not IDENTITY) | ||
| create table result | ||
| ( | ||
| id bigint not null primary key default (NEXT VALUE FOR dbo.result_sequence), | ||
| expression varchar(1000), | ||
| code varchar(255) not null check (code in | ||
| ('INVALID', 'STRUCTURE', 'REQUIRED', 'VALUE', 'INVARIANT', 'SECURITY', | ||
| 'LOGIN', 'UNKNOWN', 'EXPIRED', 'FORBIDDEN', 'SUPPRESSED', 'PROCESSING', | ||
| 'NOTSUPPORTED', 'DUPLICATE', 'MULTIPLEMATCHES', 'NOTFOUND', 'DELETED', | ||
| 'TOOLONG', 'CODEINVALID', 'EXTENSION', 'TOOCOSTLY', 'BUSINESSRULE', | ||
| 'CONFLICT', 'TRANSIENT', 'LOCKERROR', 'NOSTORE', 'EXCEPTION', | ||
| 'TIMEOUT', 'INCOMPLETE', 'THROTTLED', 'INFORMATIONAL', 'NULL')), | ||
| facility_id varchar(255) not null, | ||
| location varchar(255), | ||
| message varchar(max) not null, | ||
| patient_id varchar(255) not null, | ||
| report_id varchar(255) not null, | ||
| severity varchar(255) not null check (severity in ('FATAL', 'ERROR', 'WARNING', 'INFORMATION', 'NULL')) | ||
| ); | ||
|
|
||
| -- Recreate result_category join table | ||
| create table result_category | ||
| ( | ||
| result_id bigint not null, | ||
| category_id varchar(255) not null | ||
| ); | ||
|
|
||
| -- Indexes and constraints | ||
| if not exists (select 1 from sys.indexes where name = 'ix_result_facility_id' and object_id = object_id('result')) | ||
| create index ix_result_facility_id | ||
| on result (facility_id); | ||
|
|
||
| if not exists (select 1 from sys.indexes where name = 'ix_result_facility_id_report_id' and object_id = object_id('result')) | ||
| create index ix_result_facility_id_report_id | ||
| on result (facility_id, report_id); | ||
|
|
||
| if not exists (select 1 from sys.indexes where name = 'ix_result_facility_id_report_id_patient_id' and object_id = object_id('result')) | ||
| create index ix_result_facility_id_report_id_patient_id | ||
| on result (facility_id, report_id, patient_id); | ||
|
|
||
| if not exists (select 1 from sys.indexes where name = 'ix_result_category_result_id' and object_id = object_id('result_category')) | ||
| create index ix_result_category_result_id | ||
| on result_category (result_id); | ||
|
|
||
| if not exists (select 1 from sys.key_constraints where name = 'ix_result_category_result_id_category_id') | ||
| begin | ||
| alter table result_category | ||
| add constraint ix_result_category_result_id_category_id unique (result_id, category_id); | ||
| end; | ||
|
|
||
| -- Foreign keys | ||
| if not exists (select 1 from sys.foreign_keys where name = 'fk_result_category_category_id') | ||
| begin | ||
| alter table result_category | ||
| add constraint fk_result_category_category_id | ||
| foreign key (category_id) | ||
| references category; | ||
| end; | ||
|
|
||
| if not exists (select 1 from sys.foreign_keys where name = 'fk_result_category_result_id') | ||
| begin | ||
| alter table result_category | ||
| add constraint fk_result_category_result_id | ||
| foreign key (result_id) | ||
| references result; | ||
| end; | ||
|
|
||
| -- Ensure existing sequence uses increment 100 to match Hibernate allocationSize | ||
| IF EXISTS (SELECT 1 FROM sys.sequences WHERE name = 'result_sequence' AND schema_name(schema_id) = 'dbo') | ||
| BEGIN | ||
| ALTER SEQUENCE dbo.result_sequence | ||
| INCREMENT BY 100; | ||
| END | ||
| ELSE | ||
| BEGIN | ||
| CREATE SEQUENCE dbo.result_sequence | ||
| AS bigint | ||
| START WITH 1 | ||
| INCREMENT BY 100; | ||
| END | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.