Files
decision/crates/ld-server/migrations/0012_retired.sql
T

50 lines
2.7 KiB
SQL

-- The information on how the vote works leaves the document (2026-11-03, lot T4,
-- ADR 0014). Additive only: no row is dropped, no column an older image reads is
-- rewritten.
--
-- Yvv, 2026-11-03: « les 3 derniers modules ne sont pas de votes : ordonnancement,
-- inertie, et formule de vote sont des infos de fonctionnement. Les votes se font à
-- leur place, et les infos doivent trouver leur place dans l'ux. » The articles of the
-- sections `formule`, `inertie` and `ordonnancement`, and the order of each, are no
-- texts to vote. A new base is born without them (the seed no longer holds them); an
-- existing base keeps every row of them — units, versions, revisions, translations —
-- and marks the units retired: the document no longer lists them, counts them,
-- votes on them or publishes them. An older image (rollback) ignores the column and
-- shows them again exactly as they were.
-- When the unit left the document (NULL: it is in it), and the amendment that took it out.
ALTER TABLE units ADD COLUMN retired_at TEXT;
ALTER TABLE units ADD COLUMN retired_reason TEXT;
-- The retirement of an existing document's units (src/retire.rs): decided once per
-- document, only where no person left a trace on any of them. Each decision is kept
-- here: applied (and the codes retired), refused (why, and on which unit), or present
-- (the document was born without them).
CREATE TABLE retirement_amendments (
amendment_id TEXT NOT NULL,
doc_id TEXT NOT NULL REFERENCES documents(id),
outcome TEXT NOT NULL, -- applied | refused | present
reason TEXT, -- why it was refused
unit_code TEXT, -- the unit the trace was found on
retired TEXT, -- JSON array of the codes retired
at TEXT NOT NULL,
PRIMARY KEY (amendment_id, doc_id)
);
-- An article the seed now holds, added to an existing document (src/article_amend.rs):
-- decided once per document. Each decision is kept here: applied (the unit created,
-- where it was placed and why), refused (why), or present (born with it).
CREATE TABLE article_amendments (
amendment_id TEXT NOT NULL,
doc_id TEXT NOT NULL REFERENCES documents(id),
unit_code TEXT NOT NULL,
unit_id TEXT, -- the unit created, or found
outcome TEXT NOT NULL, -- applied | refused | present
reason TEXT, -- why it was refused
placement TEXT, -- between (where the seed puts it) | end (of its section)
placement_reason TEXT, -- why at the end
position REAL,
at TEXT NOT NULL,
PRIMARY KEY (amendment_id, doc_id)
);