95cab106d8
- PostgreSQL schema: sources, manga, chapters, pages, source_meta with indexes - golang-migrate runner with embedded SQL via go:embed (pgx5:// scheme) - sqlc-generated type-safe queries for all tables (pgx/v5 native) - Config package with all env vars including TTL durations - Wire DB init and config into cmd/server/main.go
25 lines
630 B
SQL
25 lines
630 B
SQL
-- name: UpsertSource :one
|
|
INSERT INTO sources (id, name, lang, is_nsfw)
|
|
VALUES ($1, $2, $3, $4)
|
|
ON CONFLICT (id) DO UPDATE
|
|
SET name = EXCLUDED.name,
|
|
lang = EXCLUDED.lang,
|
|
is_nsfw = EXCLUDED.is_nsfw
|
|
RETURNING *;
|
|
|
|
-- name: ListSources :many
|
|
SELECT * FROM sources ORDER BY id;
|
|
|
|
-- name: GetSourceByID :one
|
|
SELECT * FROM sources WHERE id = $1;
|
|
|
|
-- name: GetSourceMeta :one
|
|
SELECT value FROM source_meta
|
|
WHERE source_id = $1 AND key = $2;
|
|
|
|
-- name: SetSourceMeta :exec
|
|
INSERT INTO source_meta (source_id, key, value)
|
|
VALUES ($1, $2, $3)
|
|
ON CONFLICT (source_id, key) DO UPDATE
|
|
SET value = EXCLUDED.value;
|