-- A round that is abandoned is not the same as a round that settled. -- -- Settlement means an outcome was produced, which is why reveal_is_complete -- requires a settled round to publish its seed. A round whose instance died -- mid-flight has no outcome at all: there is nothing to reveal, and marking it -- settled would either violate that constraint or, worse, publish a seed for a -- round that never resolved. -- -- Voiding is its own state: stakes are returned and the round is closed with no -- result. ALTER TABLE rounds ADD COLUMN voided_at TIMESTAMPTZ; COMMENT ON COLUMN rounds.voided_at IS 'Set when a round was abandoned and its stakes refunded. Mutually exclusive with settled_at.'; ALTER TABLE rounds ADD CONSTRAINT round_not_both_settled_and_void CHECK (settled_at IS NULL OR voided_at IS NULL); CREATE INDEX rounds_unresolved_idx ON rounds (opened_at) WHERE settled_at IS NULL AND voided_at IS NULL;