Skip to content

Commit 1d54a52

Browse files
committed
rename index
1 parent 72b223a commit 1d54a52

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

coderd/database/dump.sql

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
DROP INDEX idx_user_link_linked_id;
1+
DROP INDEX user_links_linked_id_login_type_idx;

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@
44
-- linked_value, there is no way to determine correctly which user should
55
-- be updated. Since the linked_id is empty, this value will be linked
66
-- by email.
7-
UPDATE ONLY user_links out
7+
UPDATE ONLY user_links AS out
88
SET
99
linked_id =
1010
CASE WHEN (
1111
-- When the count of linked_id is greater than 1, set the linked_id to empty
12-
SELECT COUNT(*)
13-
FROM user_links inn
14-
WHERE out.linked_id = inn.linked_id AND out.login_type = inn.login_type
12+
SELECT
13+
COUNT(*)
14+
FROM
15+
user_links inn
16+
WHERE
17+
out.linked_id = inn.linked_id AND out.login_type = inn.login_type
1518
) > 1 THEN '' ELSE out.linked_id END;
1619

1720
-- 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, login_type) WHERE (linked_id != '');
21+
CREATE UNIQUE INDEX user_links_linked_id_login_type_idx ON user_links USING btree (linked_id, login_type) WHERE (linked_id != '');

coderd/database/unique_constraint.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)