-- Documenso v2 webhooks send only the numeric internal ID (`payload.id = 19`), -- but the rest of the v2 API expects the public `envelope_xxx` string that we -- already store in `documents.documenso_id`. To resolve incoming webhooks -- against our documents, capture the numeric id alongside the envelope id at -- create time and let the resolver try either column. -- -- v1 documents only have a single numeric id; existing rows leave this column -- null and continue resolving by `documenso_id` as before. ALTER TABLE documents ADD COLUMN IF NOT EXISTS documenso_numeric_id text; CREATE INDEX IF NOT EXISTS idx_docs_documenso_numeric_id ON documents(documenso_numeric_id);