-- name: InsertPromptTemplate :one
INSERT INTO prompt_templates (id, name, content, scope, owner_id)
VALUES ($1, $2, $3, $4, $5)
RETURNING *;

-- name: GetPromptTemplate :one
SELECT * FROM prompt_templates WHERE id = $1;

-- name: ListPromptTemplatesForUser :many
SELECT * FROM prompt_templates
WHERE scope = 'system' OR (scope = 'user' AND owner_id = $1)
ORDER BY scope, name;

-- name: UpdatePromptTemplate :exec
UPDATE prompt_templates SET name = $2, content = $3, updated_at = NOW()
WHERE id = $1;

-- name: DeletePromptTemplate :exec
DELETE FROM prompt_templates WHERE id = $1;
