Skip to content

Commit 7bf4dfe

Browse files
committed
fix : fix migration script
1 parent 0611bd6 commit 7bf4dfe

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
1+
-- remove exists duplicate entries from database
2+
DELETE FROM note_teams
3+
WHERE id IN (
4+
SELECT id
5+
FROM (
6+
SELECT
7+
id,
8+
ROW_NUMBER() OVER (
9+
PARTITION BY note_id, user_id
10+
ORDER BY id
11+
) AS row_num
12+
FROM note_teams
13+
) AS duplicates
14+
WHERE duplicates.row_num > 1
15+
);
16+
17+
-- adds unique index
118
CREATE UNIQUE INDEX IF NOT EXISTS note_teams_note_id_user_id_unique_idx
219
ON public.note_teams (note_id, user_id);

0 commit comments

Comments
 (0)