- build: somewhat polished dockerization setup - build: io/fs migrations with `golang-migrate` - feat: automatic init. admin account creation (.env creds) - feat(routers): combined user & token routers into single auth router - feat(routers): improved route layouts (`Routes`) - feat(middlewares): removed redundant `userCtx` middleware - fix(schema): note <-> note_versions relation (versioning) - feat(queries): removed redundant rollback functionality - feat(queries): combined duplicate version check & insertion/creation - tests: decreased redundancy by removing 'unnecessary' unit tests - refactor: hid internal packages behind `server/internal` - docs: notes & auth handler comments
34 lines
645 B
SQL
34 lines
645 B
SQL
-- name: CreateUser :one
|
|
INSERT INTO users (username, password_hash)
|
|
VALUES ($1, $2)
|
|
RETURNING *;
|
|
|
|
-- name: CreateAdmin :one
|
|
INSERT INTO users (username, password_hash, is_admin)
|
|
VALUES ($1, $2, true)
|
|
RETURNING *;
|
|
|
|
-- name: ListUsers :many
|
|
SELECT * FROM users;
|
|
|
|
-- name: ListAdmins :many
|
|
SELECT * FROM users
|
|
WHERE is_admin = true;
|
|
|
|
-- name: GetUserByID :one
|
|
SELECT * FROM users
|
|
WHERE id = $1 LIMIT 1;
|
|
|
|
-- name: GetUserByUsername :one
|
|
SELECT * FROM users
|
|
WHERE username = $1 LIMIT 1;
|
|
|
|
-- name: UpdatePassword :exec
|
|
UPDATE users
|
|
SET password_hash = $2, updated_at = NOW()
|
|
WHERE id = $1;
|
|
|
|
-- name: DeleteUser :exec
|
|
DELETE FROM users
|
|
WHERE id = $1;
|