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
14 lines
412 B
SQL
14 lines
412 B
SQL
-- name: UpsertPage :one
|
|
INSERT INTO pages (chapter_id, "index", url, image_url)
|
|
VALUES ($1, $2, $3, $4)
|
|
ON CONFLICT (chapter_id, "index") DO UPDATE
|
|
SET url = EXCLUDED.url,
|
|
image_url = EXCLUDED.image_url
|
|
RETURNING *;
|
|
|
|
-- name: ListPagesByChapter :many
|
|
SELECT * FROM pages WHERE chapter_id = $1 ORDER BY "index";
|
|
|
|
-- name: UpdatePageImageURL :exec
|
|
UPDATE pages SET image_url = $2 WHERE id = $1;
|