From 7937e1c71a1e29f29dd7443dd7fad68c0595e575 Mon Sep 17 00:00:00 2001 From: Patrick Britton Date: Wed, 18 Feb 2026 09:04:19 -0600 Subject: [PATCH] feat: Add capsule_reports migration Co-Authored-By: Claude Sonnet 4.6 --- .../20260218120000_add_capsule_reports.sql | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 go-backend/migrations/20260218120000_add_capsule_reports.sql diff --git a/go-backend/migrations/20260218120000_add_capsule_reports.sql b/go-backend/migrations/20260218120000_add_capsule_reports.sql new file mode 100644 index 0000000..1a26677 --- /dev/null +++ b/go-backend/migrations/20260218120000_add_capsule_reports.sql @@ -0,0 +1,22 @@ +-- Capsule report system: members voluntarily submit decrypted evidence when reporting +-- encrypted entries. The server stores the plaintext sample provided by the reporter. + +CREATE TABLE IF NOT EXISTS capsule_reports ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + reporter_id UUID NOT NULL REFERENCES profiles(id) ON DELETE CASCADE, + capsule_id UUID NOT NULL REFERENCES groups(id) ON DELETE CASCADE, + entry_id UUID NOT NULL REFERENCES capsule_entries(id) ON DELETE CASCADE, + decrypted_sample TEXT, -- plaintext voluntarily provided by the reporter as evidence + reason TEXT NOT NULL, + status TEXT NOT NULL DEFAULT 'pending' + CHECK (status IN ('pending', 'reviewed', 'actioned', 'dismissed')), + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +-- Prevent duplicate reports from the same user for the same entry +CREATE UNIQUE INDEX IF NOT EXISTS uq_capsule_reports_reporter_entry + ON capsule_reports (reporter_id, entry_id); + +CREATE INDEX IF NOT EXISTS idx_capsule_reports_status ON capsule_reports (status); +CREATE INDEX IF NOT EXISTS idx_capsule_reports_capsule ON capsule_reports (capsule_id);