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
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
-- 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;
|
||||
Reference in New Issue
Block a user