The user_session is valid for 24 hours, but the session will be bumped if it has been over an hour since the last update. An hour was set as a deadline, so that we would not update the user_session rows too often.
17 lines
572 B
SQL
17 lines
572 B
SQL
-- name: SelectSessionById :one
|
|
SELECT id, secret_hash, user_id, last_verified_at, created_at, updated_at
|
|
FROM user_session
|
|
WHERE id = $1;
|
|
|
|
-- name: InsertSession :one
|
|
INSERT INTO user_session (id, secret_hash, user_id)
|
|
VALUES ($1, $2, $3)
|
|
RETURNING id, secret_hash, user_id, last_verified_at, created_at, updated_at;
|
|
|
|
-- name: UpdateSessionVerifiedAt :one
|
|
UPDATE user_session SET last_verified_at = NOW()
|
|
WHERE id = $1
|
|
RETURNING id, secret_hash, user_id, last_verified_at, created_at, updated_at;
|
|
|
|
-- name: DeleteSessionById :exec
|
|
DELETE FROM user_session WHERE id = $1;
|