metatroncubeswdev c102594ca5 feat(security): log staff access to customers' personal data
DataAccessLog records bookings list/view/export and run-sheet views (actor, action,
target, time); pruned after 12 months by the worker; migration 0003.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 13:18:44 -04:00

16 lines
592 B
SQL

-- Access log for customers' personal data (who viewed or exported it, and when).
CREATE TABLE "DataAccessLog" (
"id" TEXT NOT NULL,
"shopId" TEXT NOT NULL,
"actor" TEXT NOT NULL,
"action" TEXT NOT NULL,
"target" TEXT,
"at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "DataAccessLog_pkey" PRIMARY KEY ("id")
);
CREATE INDEX "DataAccessLog_shopId_at_idx" ON "DataAccessLog"("shopId", "at");
ALTER TABLE "DataAccessLog" ADD CONSTRAINT "DataAccessLog_shopId_fkey" FOREIGN KEY ("shopId") REFERENCES "Shop"("id") ON DELETE CASCADE ON UPDATE CASCADE;