-- 092: Per-document signing authorization on signature records.
--
-- On the Standard (no-login) CMS filing path the signer gives an EXPLICIT,
-- per-document authorization to use their drawn signature to complete and submit
-- the filing on their behalf. These columns capture that authorization at
-- signing time, alongside the existing perjury attestation. They are only
-- meaningful for drawn signatures on documents that require it
-- (metadata.require_sign_consent = true); other docs leave them false/NULL.
--
-- NB: the column names use the ink_consent* prefix for historical/migration
-- compatibility; they store the generic signing authorization described above.
--
-- Idempotent.

ALTER TABLE esign_records
    ADD COLUMN IF NOT EXISTS ink_consent      BOOLEAN DEFAULT FALSE,
    ADD COLUMN IF NOT EXISTS ink_consent_at   TIMESTAMPTZ,
    ADD COLUMN IF NOT EXISTS ink_consent_text TEXT;

COMMENT ON COLUMN esign_records.ink_consent IS
    'TRUE when the signer expressly authorized using their drawn signature to '
    'complete and submit this filing. Captured at signing time.';
COMMENT ON COLUMN esign_records.ink_consent_at IS
    'When the signing authorization was given (signer-side timestamp).';
COMMENT ON COLUMN esign_records.ink_consent_text IS
    'Verbatim authorization language the signer agreed to (for the audit trail).';
