Skip to content

Commit c79f10a

Browse files
committed
add login_type check
1 parent 02d42fc commit c79f10a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

coderd/database/migrations/000205_unique_linked_id.up.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ SET
1111
-- When the count of linked_id is greater than 1, set the linked_id to empty
1212
SELECT COUNT(*)
1313
FROM user_links inn
14-
WHERE out.linked_id = inn.linked_id
14+
WHERE out.linked_id = inn.linked_id AND out.login_type = inn.login_type
1515
) > 1 THEN '' ELSE out.linked_id END;
1616

1717
-- Enforce unique linked_id constraint on non-empty linked_id
18-
CREATE UNIQUE INDEX idx_user_link_linked_id ON user_links USING btree (linked_id) WHERE (linked_id != '');
18+
CREATE UNIQUE INDEX idx_user_link_linked_id ON user_links USING btree (linked_id, login_type) WHERE (linked_id != '');

0 commit comments

Comments
 (0)