Files
paliad/internal/db/migrations/004_akten.up.sql
m 3da11bd798 chore(t-paliad-081): doc + dead-code batch (F-5/F-10/F-11/F-15/F-16/F-17/F-18)
Bundle of small audit findings, all doc-only or dead-code:

- F-5: refresh stale escalation-contact comment in models.User —
  Settings UI dropdown shipped 2026-04-29 (t-paliad-066).
- F-10: add "OBSOLETED by migration 018" note to migrations 004/005/006
  so readers stop hunting for the live shape in obsolete files.
- F-11: document the data-loss semantics of dropping
  paliad.partner_unit_events on the 027 down — audit rows are
  append-only telemetry, accepted loss on rollback.
- F-15: drop the patholo_session / patholo_refresh cookie fallback
  added during the 2026-04-16 rebrand. Active users have long since
  been re-authed through the upgrade path; inactive users hit the
  normal /login flow.
- F-16: refresh stale /api/departments comment in team_pages.go to
  /api/partner-units (renamed in t-paliad-070).
- F-17: move internal/db/migrations/_dev/mock_supabase_auth.sql to
  internal/db/devtools/ so a future loosening of the //go:embed
  pattern can't accidentally ship the dev-only fixture.
- F-18: update docs/project-status.md "Audit polish-2" entry — the
  batch shipped via t-paliad-067 / 068 / 073, follow-ups are now
  tracked under the 2026-04-30 re-audit + t-paliad-074.

go build / vet / test clean.
2026-04-30 03:42:25 +02:00

45 lines
2.2 KiB
SQL

-- Phase A: paliad.akten — the central Akte (matter) entity.
--
-- OBSOLETED by migration 018 (data model v2): paliad.akten is dropped and
-- replaced by paliad.projects. The effective shape lives in 018; this file
-- is kept only so a fresh database can replay the migration history.
--
-- Office-scoped visibility columns (per design §2):
-- owning_office — the office the Akte belongs to
-- collaborators — uuid[] of users with explicit access (cross-office)
-- firm_wide_visible — partner-toggled override for firm-wide matters
--
-- Visibility enforcement lives in paliad.can_see_akte() (migration 006)
-- and is applied through the RLS policies (migration 007).
CREATE TABLE paliad.akten (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
aktenzeichen text NOT NULL,
title text NOT NULL,
akte_type text,
court text,
court_ref text,
status text NOT NULL DEFAULT 'active'
CHECK (status IN ('active', 'pending', 'closed', 'archived')),
ai_summary text,
-- Visibility model
owning_office text NOT NULL CHECK (owning_office IN (
'munich', 'duesseldorf', 'hamburg',
'amsterdam', 'london', 'paris', 'milan'
)),
collaborators uuid[] NOT NULL DEFAULT '{}',
firm_wide_visible boolean NOT NULL DEFAULT false,
created_by uuid REFERENCES auth.users(id) ON DELETE SET NULL,
metadata jsonb NOT NULL DEFAULT '{}',
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX akten_status_owning_office_idx ON paliad.akten (status, owning_office);
CREATE INDEX akten_owning_office_idx ON paliad.akten (owning_office);
CREATE INDEX akten_firm_wide_idx ON paliad.akten (firm_wide_visible) WHERE firm_wide_visible = true;
-- GIN index on collaborators lets the visibility predicate use `ANY(collaborators)` efficiently.
CREATE INDEX akten_collaborators_gin_idx ON paliad.akten USING GIN (collaborators);