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>
58 lines
1.1 KiB
SQL
58 lines
1.1 KiB
SQL
-- name: CreateDinner :one
|
|
INSERT INTO dinners (
|
|
id, name, normalized_name, status, origin, method, minutes_total,
|
|
difficulty, cuisine, is_favorite, recipe_id, photo_id, grounding_status,
|
|
updated_by, created_at, updated_at
|
|
) VALUES (
|
|
?, ?, ?, ?, ?, ?, ?,
|
|
?, ?, ?, ?, ?, ?,
|
|
?, ?, ?
|
|
)
|
|
RETURNING *;
|
|
|
|
-- name: GetDinner :one
|
|
SELECT * FROM dinners
|
|
WHERE id = ?;
|
|
|
|
-- name: ListDinnersByStatus :many
|
|
SELECT * FROM dinners
|
|
WHERE status = ?
|
|
ORDER BY normalized_name, id;
|
|
|
|
-- name: UpdateDinner :one
|
|
-- An unknown id returns sql.ErrNoRows.
|
|
UPDATE dinners
|
|
SET name = ?,
|
|
normalized_name = ?,
|
|
status = ?,
|
|
origin = ?,
|
|
method = ?,
|
|
minutes_total = ?,
|
|
difficulty = ?,
|
|
cuisine = ?,
|
|
recipe_id = ?,
|
|
photo_id = ?,
|
|
grounding_status = ?,
|
|
updated_by = ?,
|
|
updated_at = ?
|
|
WHERE id = ?
|
|
RETURNING *;
|
|
|
|
-- name: ArchiveDinner :one
|
|
-- An unknown id returns sql.ErrNoRows.
|
|
UPDATE dinners
|
|
SET status = 'archived',
|
|
updated_by = ?,
|
|
updated_at = ?
|
|
WHERE id = ?
|
|
RETURNING *;
|
|
|
|
-- name: SetDinnerFavorite :one
|
|
-- An unknown id returns sql.ErrNoRows.
|
|
UPDATE dinners
|
|
SET is_favorite = ?,
|
|
updated_by = ?,
|
|
updated_at = ?
|
|
WHERE id = ?
|
|
RETURNING *;
|