Skip to content

Commit

Permalink
LANTERN-595, LANTERN-596: Removal and prevention of duplicate rows in…
Browse files Browse the repository at this point in the history
… healthit_products_map
  • Loading branch information
archita-ekkirala committed Aug 8, 2024
1 parent 64e3c6c commit 5341440
Show file tree
Hide file tree
Showing 2 changed files with 565 additions and 544 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
BEGIN;


CREATE OR REPLACE FUNCTION delete_duplicate_data_in_healthit_products_map() RETURNS VOID as $$
BEGIN
WITH CTE AS (
SELECT
ctid,
ROW_NUMBER() OVER(PARTITION BY id, healthit_product_id ORDER BY id) AS DuplicateCount
FROM
public.healthit_products_map
)
DELETE FROM public.healthit_products_map
WHERE ctid IN (
SELECT ctid
FROM CTE
WHERE DuplicateCount > 1
);
END;
$$ LANGUAGE plpgsql;

SELECT delete_duplicate_data_in_healthit_products_map();

COMMIT;
Loading

0 comments on commit 5341440

Please sign in to comment.