Files
iios/packages/iios-service/prisma/migrations/20260703070438_retention_sweep/migration.sql
T
maaz519 035315ef73 feat(iios): retention_policy_snapshot + sweep (archive→redact, hold-aware) (P9)
Adds IiosRetentionPolicySnapshot (per-interaction frozen lifecycle timestamps)
+ IiosInteraction.dataClass, and a RetentionService whose sweep captures
snapshots then archives (status change) and, past delete_after, redacts content
in place (reusing the Slice-8 tombstone) — never a hard delete. An active
compliance hold blocks both; every action is audited and tenant-scopeable.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-03 12:50:49 +05:30

30 lines
1.1 KiB
SQL

-- AlterTable
ALTER TABLE "IiosInteraction" ADD COLUMN "dataClass" TEXT NOT NULL DEFAULT 'internal';
-- CreateTable
CREATE TABLE "IiosRetentionPolicySnapshot" (
"id" TEXT NOT NULL,
"policyKey" TEXT NOT NULL,
"scopeSnapshotId" TEXT NOT NULL,
"targetType" TEXT NOT NULL,
"targetId" TEXT NOT NULL,
"dataClass" TEXT NOT NULL,
"retainUntil" TIMESTAMP(3),
"archiveAfter" TIMESTAMP(3) NOT NULL,
"deleteAfter" TIMESTAMP(3) NOT NULL,
"sourceVersion" TEXT NOT NULL DEFAULT 'v1',
"status" TEXT NOT NULL DEFAULT 'ACTIVE',
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "IiosRetentionPolicySnapshot_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "IiosRetentionPolicySnapshot_status_deleteAfter_idx" ON "IiosRetentionPolicySnapshot"("status", "deleteAfter");
-- CreateIndex
CREATE INDEX "IiosRetentionPolicySnapshot_scopeSnapshotId_status_idx" ON "IiosRetentionPolicySnapshot"("scopeSnapshotId", "status");
-- CreateIndex
CREATE UNIQUE INDEX "IiosRetentionPolicySnapshot_targetType_targetId_key" ON "IiosRetentionPolicySnapshot"("targetType", "targetId");