Skip to content

Commit

Permalink
feat: CLIN-2173 removed unique index
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethienne Roy committed Aug 24, 2023
1 parent 8da9ffe commit 41fd1c3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions migrations/1692886119429_remove-unique-constraint.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- Up Migration
drop index idx_unique_saved_filters;

drop function get_filter_uniqueness_date();
-- Down Migration
CREATE OR REPLACE FUNCTION get_filter_uniqueness_date() RETURNS timestamp AS $$
declare run_on_date timestamp;
BEGIN
SELECT run_on into run_on_date
FROM pgmigrations
WHERE name = '1688561786592_update-saved-filter';

RETURN run_on_date;
END
$$ LANGUAGE plpgsql
IMMUTABLE;;

CREATE UNIQUE INDEX idx_unique_saved_filters
ON saved_filters (title, keycloak_id, type)
WHERE creation_date > get_filter_uniqueness_date();
2 changes: 1 addition & 1 deletion src/utils/savedFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const getCount = (filter) =>
type: QueryTypes.SELECT,
},
)
.then((res) => res[0]['count']);
.then((res) => Number(res[0]['count']));

export const handleUniqueName = async (filter) => {
if (!filter.title) {
Expand Down

0 comments on commit 41fd1c3

Please sign in to comment.