-- name: EnsureCounter :exec INSERT INTO core_counter (id, value) VALUES (@id::text, 0) ON CONFLICT DO NOTHING; -- name: IncrementCounter :one UPDATE core_counter SET value = value + 1 WHERE id = @id::text RETURNING value::int; -- name: BumpCounter :exec UPDATE core_counter SET value = value + 1 WHERE id = @id::text AND value <= @value::int;