Skip to content

Commit

Permalink
#4247 - Create Application Versioning (Part 2)
Browse files Browse the repository at this point in the history
- SQL Queries
  • Loading branch information
sh16011993 committed Feb 6, 2025
1 parent 80f75b9 commit 99ec5bd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@ ADD

COMMENT ON COLUMN sims.applications.preceding_application_id IS 'The immediate previous application from which the current application was created.';

-- Set parent-application-id and preceding-application-id for non-draft applications when application number is present.
-- Create indexes for parent-application-id and preceding-application-id to improve the performance of data retrieval.
CREATE INDEX preceding_application_id_idx ON sims.applications (preceding_application_id);

COMMENT ON INDEX sims.preceding_application_id_idx IS 'Index created on preceding_application_id to improve the performance of data retrieval.';

CREATE INDEX parent_application_id_idx ON sims.applications (parent_application_id);

COMMENT ON INDEX sims.parent_application_id_idx IS 'Index created on parent_application_id_idx to improve the performance of data retrieval.';

-- Set parent-application-id for applications when application number is present.
UPDATE
sims.applications
SET
Expand All @@ -27,7 +36,15 @@ SET
applications.submitted_date
LIMIT
1
), preceding_application_id = COALESCE(
)
WHERE
application_number IS NOT NULL;

-- Set preceding-application-id for applications when application number is present.
UPDATE
sims.applications
SET
preceding_application_id = COALESCE(
(
SELECT
id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
DROP INDEX sims.parent_application_id_idx,
sims.preceding_application_id_idx;

ALTER TABLE
sims.applications DROP CONSTRAINT parent_application_id_constraint,
DROP CONSTRAINT preceding_application_id_constraint;
Expand Down

0 comments on commit 99ec5bd

Please sign in to comment.