82 lines
1.2 KiB
SQL
82 lines
1.2 KiB
SQL
-- name: CreatePractice :one
|
|
INSERT INTO practices (
|
|
owner_type,
|
|
owner_id,
|
|
title,
|
|
description,
|
|
banner_image,
|
|
persona,
|
|
is_active
|
|
)
|
|
VALUES (
|
|
$1, -- owner_type (LEVEL | MODULE)
|
|
$2, -- owner_id
|
|
$3, -- title
|
|
$4, -- description
|
|
$5, -- banner_image
|
|
$6, -- persona
|
|
$7 -- is_active
|
|
)
|
|
RETURNING
|
|
id,
|
|
owner_type,
|
|
owner_id,
|
|
title,
|
|
description,
|
|
banner_image,
|
|
persona,
|
|
is_active;
|
|
|
|
-- name: GetPracticeByID :one
|
|
SELECT
|
|
id,
|
|
owner_type,
|
|
owner_id,
|
|
title,
|
|
description,
|
|
banner_image,
|
|
persona,
|
|
is_active
|
|
FROM practices
|
|
WHERE id = $1;
|
|
|
|
-- name: ListPracticesByOwner :many
|
|
SELECT
|
|
id,
|
|
owner_type,
|
|
owner_id,
|
|
title,
|
|
description,
|
|
banner_image,
|
|
persona,
|
|
is_active
|
|
FROM practices
|
|
WHERE owner_type = $1
|
|
AND owner_id = $2
|
|
AND is_active = TRUE
|
|
ORDER BY id ASC;
|
|
|
|
-- name: UpdatePractice :one
|
|
UPDATE practices
|
|
SET
|
|
title = $2,
|
|
description = $3,
|
|
banner_image = $4,
|
|
persona = $5,
|
|
is_active = $6
|
|
WHERE id = $1
|
|
RETURNING
|
|
id,
|
|
owner_type,
|
|
owner_id,
|
|
title,
|
|
description,
|
|
banner_image,
|
|
persona,
|
|
is_active;
|
|
|
|
-- name: DeactivatePractice :exec
|
|
UPDATE practices
|
|
SET is_active = FALSE
|
|
WHERE id = $1;
|