Skip to content

Commit eb266db

Browse files
committed
fix login_type query
1 parent 940ced4 commit eb266db

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

coderd/database/migrations/000034_linked_user_id.up.sql

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ SELECT
3737
FROM
3838
(
3939
SELECT
40-
row_number() OVER (partition by user_id, login_type ORDER BY updated_at DESC) AS x,
40+
row_number() OVER (partition by user_id, login_type ORDER BY last_used DESC) AS x,
4141
api_keys.* FROM api_keys
4242
) as keys
4343
WHERE x=1 AND keys.login_type != 'password';
@@ -63,7 +63,12 @@ SET
6363
user_links
6464
WHERE
6565
user_links.user_id = users.id
66+
ORDER BY oauth_expiry DESC
6667
LIMIT 1
67-
);
68+
)
69+
FROM
70+
user_links
71+
WHERE
72+
user_links.user_id = users.id;
6873

6974
COMMIT;

0 commit comments

Comments
 (0)