mirror of
https://github.com/zoriya/Kyoo.git
synced 2026-05-20 14:22:47 -04:00
Move pk to int autogen and uuid as handle
This commit is contained in:
@@ -5,7 +5,7 @@ select
|
||||
sqlc.embed(u)
|
||||
from
|
||||
users as u
|
||||
inner join sessions as s on u.id = s.user_id
|
||||
inner join sessions as s on u.pk = s.user_pk
|
||||
where
|
||||
s.token = $1
|
||||
limit 1;
|
||||
@@ -20,24 +20,26 @@ where
|
||||
|
||||
-- name: GetUserSessions :many
|
||||
select
|
||||
*
|
||||
s.*
|
||||
from
|
||||
sessions
|
||||
sessions as s
|
||||
inner join users as u on u.pk = s.user_pk
|
||||
where
|
||||
user_id = $1
|
||||
u.pk = $1
|
||||
order by
|
||||
last_used;
|
||||
|
||||
-- name: CreateSession :one
|
||||
insert into sessions(token, user_id, device)
|
||||
insert into sessions(token, user_pk, device)
|
||||
values ($1, $2, $3)
|
||||
returning
|
||||
*;
|
||||
|
||||
-- name: DeleteSession :one
|
||||
delete from sessions
|
||||
where id = $1
|
||||
and user_id = $2
|
||||
delete from sessions as s using users as u
|
||||
where s.user_pk = u.pk
|
||||
and s.id = $1
|
||||
and u.id = sqlc.arg(user_id)
|
||||
returning
|
||||
*;
|
||||
s.*;
|
||||
|
||||
|
||||
@@ -21,10 +21,13 @@ limit $1;
|
||||
-- name: GetUser :many
|
||||
select
|
||||
sqlc.embed(u),
|
||||
sqlc.embed(h)
|
||||
h.provider,
|
||||
h.id,
|
||||
h.username,
|
||||
h.profile_url
|
||||
from
|
||||
users as u
|
||||
left join oidc_handle as h on u.id = h.user_id
|
||||
left join oidc_handle as h on u.pk = h.user_pk
|
||||
where
|
||||
u.id = $1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user