-- name: CreatePractice :one
INSERT INTO practices (
    owner_type,
    owner_id,
    title,
    description,
    banner_image,
    persona,
    is_active
)
VALUES ($1, $2, $3, $4, $5, $6, COALESCE($7, true))
RETURNING *;


-- name: GetPracticesByOwner :many
SELECT *
FROM practices
WHERE owner_type = $1
  AND owner_id = $2
  AND is_active = true;


-- name: UpdatePractice :exec
UPDATE practices
SET
    title = COALESCE($1, title),
    description = COALESCE($2, description),
    banner_image = COALESCE($3, banner_image),
    persona = COALESCE($4, persona),
    is_active = COALESCE($5, is_active)
WHERE id = $6;


-- name: DeletePractice :exec
DELETE FROM practices
WHERE id = $1;
