Adds GET /api/me/export streaming a deterministic .zip bundle of the caller's RLS-visible projection (per design §2.3): projects, deadlines, appointments, parties, notes, documents (metadata), audit events, approval requests, checklist instances + personal sidecars (me row, caldav config without ciphertext, views, pins, card layouts, paliadin turns) + reference data (proceeding_types, event_types, deadline_rules, courts, countries, holidays …) + restricted users_referenced sheet. Bundle shape: paliad-export.xlsx + paliad-export.json + per-sheet CSVs (UTF-8 BOM, RFC 4180) + README.txt + __meta.json. Outer zip is byte-deterministic — sorted file list, fixed Modified time on every entry, sorted JSON keys. Two runs at same row-state → identical bytes. ExportService.WritePersonal owns the SQL recipe + column discovery + PII deny-regex (?i)secret|token|password|api[_-]?key|private[_-]?key + per-sheet DropColumns belt-and-braces (e.g. user_caldav_config .password_encrypted explicitly dropped on top of the regex). Audit row written to paliad.system_audit_log before the run, patched with row_counts + file_size_bytes after. Migration 102 creates paliad.system_audit_log (generic event_type + actor_id/email + scope + scope_root + metadata jsonb). Idempotent CREATE TABLE IF NOT EXISTS + indexes; RLS enabled with self-read + admin-read policies. AuditService.ListEntries gains a 6th UNION branch so the new table surfaces on /admin/audit-log. excelize/v2 added to go.mod for xlsx generation. Pure-function tests pin formatCellValue value-coercion, PII regex, CSV quoting + BOM + umlaut survival, JSON shape, meta key order stability, filename slugify, and byte-determinism of the bundle assembly. Design: docs/design-paliad-data-export-2026-05-19.md §7 Slice 1.
16 lines
636 B
SQL
16 lines
636 B
SQL
-- Revert mig 102 — drop paliad.system_audit_log and its indexes / policies.
|
|
-- audit_reason set_config required by the mig 079 trigger pattern.
|
|
|
|
SELECT set_config(
|
|
'paliad.audit_reason',
|
|
'mig 102 down: drop paliad.system_audit_log (t-paliad-214 Slice 1 revert)',
|
|
true);
|
|
|
|
DROP POLICY IF EXISTS system_audit_log_select_admin ON paliad.system_audit_log;
|
|
DROP POLICY IF EXISTS system_audit_log_select_self ON paliad.system_audit_log;
|
|
|
|
DROP INDEX IF EXISTS paliad.system_audit_log_event_type_created_at_idx;
|
|
DROP INDEX IF EXISTS paliad.system_audit_log_actor_id_created_at_idx;
|
|
|
|
DROP TABLE IF EXISTS paliad.system_audit_log;
|