Files
bbq/db/queries.sql
T
ryan 7b0efb3c45 Add markdown event descriptions for hosts to provide context
Hosts can now add a free-form description (with markdown rendering via
goldmark) when creating or editing events. Descriptions render safely
with no raw HTML passthrough. Includes ALTER TABLE migration for
existing databases.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-17 08:02:24 -04:00

71 lines
1.7 KiB
SQL

-- name: GetEventBySlug :one
SELECT * FROM events WHERE slug = ?;
-- name: GetEventByAdminToken :one
SELECT * FROM events WHERE admin_token = ?;
-- name: CreateEvent :one
INSERT INTO events (slug, title, date, time, location, admin_token, description)
VALUES (?, ?, ?, ?, ?, ?, ?)
RETURNING *;
-- name: UpdateEventDescription :exec
UPDATE events SET description = ? WHERE id = ?;
-- name: UpdateEvent :exec
UPDATE events SET title = ?, date = ?, time = ?, location = ? WHERE id = ?;
-- name: DeleteEvent :exec
DELETE FROM events WHERE id = ?;
-- name: ListSlots :many
SELECT * FROM slots WHERE event_id = ? ORDER BY sort_order, id;
-- name: GetSlot :one
SELECT * FROM slots WHERE id = ?;
-- name: CreateSlot :one
INSERT INTO slots (event_id, name, emoji, max_claims, sort_order)
VALUES (?, ?, ?, ?, ?)
RETURNING *;
-- name: UpdateSlot :exec
UPDATE slots SET name = ?, emoji = ?, max_claims = ? WHERE id = ?;
-- name: DeleteSlot :exec
DELETE FROM slots WHERE id = ?;
-- name: ListClaimsBySlot :many
SELECT * FROM claims WHERE slot_id = ? ORDER BY created_at;
-- name: ListClaimsByEvent :many
SELECT c.* FROM claims c
JOIN slots s ON c.slot_id = s.id
WHERE s.event_id = ?
ORDER BY c.slot_id, c.created_at;
-- name: CreateClaim :one
INSERT INTO claims (slot_id, name, note)
VALUES (?, ?, ?)
RETURNING *;
-- name: DeleteClaim :exec
DELETE FROM claims WHERE id = ?;
-- name: CountClaimsBySlot :one
SELECT COUNT(*) FROM claims WHERE slot_id = ?;
-- name: ListRsvps :many
SELECT * FROM rsvps WHERE event_id = ? ORDER BY created_at;
-- name: CreateRsvp :one
INSERT INTO rsvps (event_id, name, note)
VALUES (?, ?, ?)
RETURNING *;
-- name: DeleteRsvp :exec
DELETE FROM rsvps WHERE id = ?;
-- name: CountRsvps :one
SELECT COUNT(*) FROM rsvps WHERE event_id = ?;