fix: address per-document audit log review feedback

- backfill DocumentMeta.includeAuditLog from the effective team/org
  setting so documents created before the column keep embedding audit
  logs after deploy
- default includeAuditLog in the webhook payload schema so resending
  historical WebhookCall payloads stays backward-compatible
- allow audit-log embedding to be changed after a document is sent
  (drop the server guards and the editor checkbox lock)
- restore the commented change-detection block in updateEnvelope
This commit is contained in:
ephraimduncan
2026-06-16 11:40:36 +00:00
parent ecc99b8e4f
commit 77889270b8
5 changed files with 53 additions and 61 deletions
@@ -1,2 +1,16 @@
-- AlterTable
ALTER TABLE "DocumentMeta" ADD COLUMN "includeAuditLog" BOOLEAN NOT NULL DEFAULT false;
-- Backfill existing rows from the effective team/organisation setting. Before this
-- column existed the sealing flow read `includeAuditLog` from the team settings
-- (falling back to the organisation default), so documents created prior to this
-- migration must keep that resolved value to avoid silently dropping audit-log
-- embedding after deploy.
UPDATE "DocumentMeta" AS dm
SET "includeAuditLog" = COALESCE(tgs."includeAuditLog", ogs."includeAuditLog")
FROM "Envelope" e
JOIN "Team" t ON t."id" = e."teamId"
JOIN "TeamGlobalSettings" tgs ON tgs."id" = t."teamGlobalSettingsId"
JOIN "Organisation" o ON o."id" = t."organisationId"
JOIN "OrganisationGlobalSettings" ogs ON ogs."id" = o."organisationGlobalSettingsId"
WHERE e."documentMetaId" = dm."id";