You've already forked agentic-coding-workflow
feat(project): domain types and sqlc queries for project/requirement/issue
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
-- name: CreateRequirement :one
|
||||
INSERT INTO requirements (id, project_id, number, title, description, owner_id)
|
||||
VALUES (
|
||||
$1, $2,
|
||||
(SELECT COALESCE(MAX(number), 0) + 1 FROM requirements WHERE project_id = $2),
|
||||
$3, $4, $5
|
||||
)
|
||||
RETURNING id, project_id, number, title, description, phase, status, owner_id,
|
||||
closed_at, created_at, updated_at;
|
||||
|
||||
-- name: GetRequirementByNumber :one
|
||||
SELECT id, project_id, number, title, description, phase, status, owner_id,
|
||||
closed_at, created_at, updated_at
|
||||
FROM requirements
|
||||
WHERE project_id = $1 AND number = $2;
|
||||
|
||||
-- name: GetRequirementByID :one
|
||||
SELECT id, project_id, number, title, description, phase, status, owner_id,
|
||||
closed_at, created_at, updated_at
|
||||
FROM requirements WHERE id = $1;
|
||||
|
||||
-- name: ListRequirements :many
|
||||
SELECT id, project_id, number, title, description, phase, status, owner_id,
|
||||
closed_at, created_at, updated_at
|
||||
FROM requirements
|
||||
WHERE project_id = $1
|
||||
AND (sqlc.narg('phase')::text IS NULL OR phase = sqlc.narg('phase'))
|
||||
AND (sqlc.narg('status')::text IS NULL OR status = sqlc.narg('status'))
|
||||
ORDER BY number DESC;
|
||||
|
||||
-- name: UpdateRequirement :one
|
||||
UPDATE requirements
|
||||
SET title = $2,
|
||||
description = $3,
|
||||
owner_id = $4,
|
||||
updated_at = now()
|
||||
WHERE id = $1
|
||||
RETURNING id, project_id, number, title, description, phase, status, owner_id,
|
||||
closed_at, created_at, updated_at;
|
||||
|
||||
-- name: UpdateRequirementPhase :one
|
||||
UPDATE requirements
|
||||
SET phase = $2, updated_at = now()
|
||||
WHERE id = $1
|
||||
RETURNING id, project_id, number, title, description, phase, status, owner_id,
|
||||
closed_at, created_at, updated_at;
|
||||
|
||||
-- name: CloseRequirement :exec
|
||||
UPDATE requirements
|
||||
SET status = 'closed', closed_at = now(), updated_at = now()
|
||||
WHERE id = $1 AND status = 'open';
|
||||
|
||||
-- name: ReopenRequirement :exec
|
||||
UPDATE requirements
|
||||
SET status = 'open', closed_at = NULL, updated_at = now()
|
||||
WHERE id = $1 AND status = 'closed';
|
||||
Reference in New Issue
Block a user