sqlc.yaml (sqlite, schema migrations/, queries migrations/queries/) generates internal/db with emit_interface. Queries cover dinners (create, get, list by status, update, archive, set favorite), recipes with ingredients and steps (upsert by source_url, get, replace children), photos (insert, get by sha256) and get/upsert for the five settings singletons. Repository tests run every query against a migrated temp database. make sqlc regenerates with the pinned sqlc v1.31.1 (dev tool only, not in go.mod); make sqlc-check regenerates and fails on any drift in internal/db, and CI runs it after make test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
18 lines
423 B
SQL
18 lines
423 B
SQL
-- name: CreatePhoto :one
|
|
INSERT INTO photos (
|
|
id, source_url, local_path, width, height, sha256, fetched_at,
|
|
created_at, updated_at
|
|
) VALUES (
|
|
?, ?, ?, ?, ?, ?, ?,
|
|
?, ?
|
|
)
|
|
RETURNING *;
|
|
|
|
-- name: GetPhotoBySHA256 :one
|
|
-- Finds stored image bytes by content hash. The schema does not make sha256
|
|
-- unique, so the earliest-created (lowest id) match is returned.
|
|
SELECT * FROM photos
|
|
WHERE sha256 = ?
|
|
ORDER BY id
|
|
LIMIT 1;
|