-- name: EnsureCounter :exec
INSERT INTO core_counter (id, value) VALUES ($1::text, 0) ON CONFLICT DO NOTHING;

-- name: IncrementCounter :one
UPDATE core_counter SET value = value + 1 WHERE id = $1::text RETURNING value::int;

-- name: BumpCounter :exec
UPDATE core_counter SET value = value + 1 WHERE id = sqlc.arg(id)::text AND value <= sqlc.arg(value)::int;