Files
goyomi/internal/db/queries/source.sql
T
achmad 95cab106d8 feat: Phase 2 — database layer
- 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
2026-05-10 21:32:40 +07:00

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;