Refs #67 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
14 lines
600 B
SQL
14 lines
600 B
SQL
-- name: UpsertLegalDocument :exec
|
|
INSERT INTO legal_documents (org_id, kind, url, markdown)
|
|
VALUES ($1, $2, $3, $4)
|
|
ON CONFLICT (org_id, kind) DO UPDATE SET url = EXCLUDED.url, markdown = EXCLUDED.markdown, updated_at = now();
|
|
|
|
-- name: DeleteLegalDocument :exec
|
|
DELETE FROM legal_documents WHERE org_id IS NOT DISTINCT FROM $1 AND kind = $2;
|
|
|
|
-- name: LegalDocuments :many
|
|
-- The organization's documents and the platform's, organization first.
|
|
SELECT org_id, kind, url, markdown, updated_at FROM legal_documents
|
|
WHERE org_id IS NULL OR org_id = sqlc.narg(org_id)
|
|
ORDER BY org_id NULLS LAST, kind;
|