-- name: ExamPrepCreateLessonPractice :one INSERT INTO exam_prep.lesson_practices ( unit_module_lesson_id, title, story_description, story_image, persona_id, question_set_id, quick_tips ) VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING *; -- name: ExamPrepGetLessonPracticeByID :one SELECT * FROM exam_prep.lesson_practices WHERE id = $1; -- name: ExamPrepListLessonPracticesByLessonID :many SELECT COUNT(*) OVER () AS total_count, p.id, p.unit_module_lesson_id, p.title, p.story_description, p.story_image, p.persona_id, p.question_set_id, p.quick_tips, p.created_at, p.updated_at FROM exam_prep.lesson_practices p WHERE p.unit_module_lesson_id = $1 ORDER BY p.created_at DESC LIMIT $2 OFFSET $3; -- name: ExamPrepUpdateLessonPractice :one UPDATE exam_prep.lesson_practices SET title = coalesce(sqlc.narg('title')::varchar, title), story_description = coalesce(sqlc.narg('story_description')::text, story_description), story_image = coalesce(sqlc.narg('story_image')::text, story_image), persona_id = coalesce(sqlc.narg('persona_id')::bigint, persona_id), question_set_id = coalesce(sqlc.narg('question_set_id')::bigint, question_set_id), quick_tips = coalesce(sqlc.narg('quick_tips')::text, quick_tips), updated_at = CURRENT_TIMESTAMP WHERE id = sqlc.arg('id') RETURNING *; -- name: ExamPrepDeleteLessonPractice :exec DELETE FROM exam_prep.lesson_practices WHERE id = $1;