-- Putting a finished task out of the way, without pretending it never happened.
--
-- A column rather than a state. Archiving is a fact about the *list* — whether
-- you still want to see the row — while the state is a fact about the work, and
-- a task that ends `committed` and one that ends `cancelled` are not the same
-- thing afterwards. Folding both into one `archived` state would answer "is it
-- out of the way" by destroying the answer to "how did it end", and there is no
-- way back from that once the row is written.
--
-- Nullable, and null is the default, so every existing task is unarchived and
-- nothing has to be backfilled. `ALTER TABLE ADD COLUMN` also leaves the CHECK
-- constraints and the index alone, which the 0002 rebuild could not.

-- When it was put away. Null means it is still on the list.
ALTER TABLE tasks ADD COLUMN archived_at INTEGER;

-- The list asks "everything not archived, in id order" on every tick, which is
-- the one read that happens four times a second for as long as marver is open.
CREATE INDEX tasks_archived_idx ON tasks (archived_at, id);
