textmachine/platform/internal/pgstore/migrations/00014_stop_intent.sql

20 lines
1.1 KiB
SQL

-- +goose Up
-- When THIS platform asked the run to stop.
--
-- It exists because the exit marker cannot answer "who ended this run". The engine catches SIGTERM
-- and exits with code 1, so `ExecStopPost` records `exit-code/exited/1` for a stop a user pressed
-- and for a crash alike (register row PD-152, measured on the stand). Guessing from the code would
-- be reading someone else's tea leaves; this column is the platform's OWN knowledge, written before
-- the signal is sent, and the reconciler classifies the marker by it.
--
-- The order matters and is the whole point: the intent is committed BEFORE systemd is asked, so a
-- platform that dies between the two still knows, on its next sweep, that the run it finds stopped
-- was stopped on purpose — and that it must not restart it.
--
-- Null means nobody asked. Cleared when a run is re-opened, because a resumed run has not been
-- asked to stop; a stale intent would classify its next ending as a stop nobody requested.
alter table runs add column stop_requested_at timestamptz;
-- +goose Down
alter table runs drop column stop_requested_at;