target-revenue/migrations/0003_attestations.sql

25 lines
1,023 B
MySQL
Raw Normal View History

-- WP-0006-T06: Conversion Attestation publication.
-- Depends on migrations/0001_registries.sql and 0002_ledger.sql.
BEGIN;
-- One attestation per Phase, ever. A Phase converts at most once (there is
-- no "un-converting"), so this table has no update path by design, not
-- merely by omitted grant: publish_attestation() in
-- src/target_revenue/attestation.py treats an existing row as the
-- authoritative, already-published record and never attempts to replace it.
CREATE TABLE IF NOT EXISTS attestations (
phase_id text PRIMARY KEY REFERENCES phase_manifests(phase_id),
attestation jsonb NOT NULL,
signature text NOT NULL,
published_at timestamptz NOT NULL DEFAULT now()
);
GRANT SELECT, INSERT ON attestations TO trf_app;
-- Deliberately no UPDATE, no DELETE for trf_app: a published attestation is
-- a permanent historical record of an already-true fact, never subject to
-- revision (ADR-0002 compensating guardrail pattern, same as
-- phase_manifests and ledger_entries).
COMMIT;