Adds DELETE /practices/:id/parents/:parentKind/:parentId and exam-prep equivalent so admins can remove one location link without replacing the full parents array. Includes admin panel integration guide and parent kind parse tests. Co-authored-by: Cursor <cursoragent@cursor.com>
50 lines
1.3 KiB
SQL
50 lines
1.3 KiB
SQL
-- name: InsertExamPrepPracticeParent :one
|
|
INSERT INTO exam_prep.practice_parents (practice_id, parent_kind, parent_id)
|
|
VALUES ($1, $2, $3)
|
|
RETURNING *;
|
|
|
|
-- name: DeleteExamPrepPracticeParentsByPracticeID :exec
|
|
DELETE FROM exam_prep.practice_parents
|
|
WHERE practice_id = $1;
|
|
|
|
-- name: DeleteExamPrepPracticeParent :execrows
|
|
DELETE FROM exam_prep.practice_parents
|
|
WHERE practice_id = $1
|
|
AND parent_kind = $2
|
|
AND parent_id = $3;
|
|
|
|
-- name: ListExamPrepPracticeParentsByPracticeID :many
|
|
SELECT *
|
|
FROM exam_prep.practice_parents
|
|
WHERE practice_id = $1
|
|
ORDER BY id ASC;
|
|
|
|
-- name: ListExamPrepPracticeParentsByPracticeIDs :many
|
|
SELECT *
|
|
FROM exam_prep.practice_parents
|
|
WHERE practice_id = ANY (sqlc.arg('practice_ids')::bigint[])
|
|
ORDER BY practice_id ASC, id ASC;
|
|
|
|
-- name: CountExamPrepPracticesByParent :one
|
|
SELECT COUNT(*)::bigint
|
|
FROM exam_prep.practice_parents
|
|
WHERE parent_kind = $1
|
|
AND parent_id = $2;
|
|
|
|
-- name: CountExamPrepPracticesByParentExcludingPractice :one
|
|
SELECT COUNT(*)::bigint
|
|
FROM exam_prep.practice_parents
|
|
WHERE parent_kind = $1
|
|
AND parent_id = $2
|
|
AND practice_id <> $3;
|
|
|
|
-- name: ListExamPrepPracticeParentsByQuestionSetID :many
|
|
SELECT
|
|
pp.parent_kind,
|
|
pp.parent_id,
|
|
pp.practice_id
|
|
FROM exam_prep.practice_parents pp
|
|
INNER JOIN exam_prep.lesson_practices p ON p.id = pp.practice_id
|
|
WHERE p.question_set_id = $1
|
|
ORDER BY p.id DESC, pp.id ASC;
|