Files
paliad/internal/db/devtools/mock_supabase_auth.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

36 lines
1.1 KiB
PL/PgSQL

-- Mock Supabase auth schema for local migration testing.
-- In real Supabase, the auth schema + auth.users table + auth.uid() function
-- are created by the platform; locally we simulate them.
--
-- Usage: psql <DATABASE_URL> -f internal/db/migrations/_dev/mock_supabase_auth.sql
--
-- For visibility tests, set the GUC paliad_test.uid in a transaction:
-- BEGIN;
-- SET LOCAL paliad_test.uid = '<some-user-uuid>';
-- SELECT paliad.can_see_akte('<some-akte-uuid>');
-- COMMIT;
--
-- _dev/ prefix excludes this file from golang-migrate's source pattern
-- (which only reads top-level *.sql in the migrations dir).
CREATE SCHEMA IF NOT EXISTS auth;
CREATE TABLE IF NOT EXISTS auth.users (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
email text NOT NULL UNIQUE
);
CREATE OR REPLACE FUNCTION auth.uid() RETURNS uuid
LANGUAGE sql STABLE AS $$
SELECT NULLIF(current_setting('paliad_test.uid', true), '')::uuid;
$$;
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'authenticated') THEN
CREATE ROLE authenticated;
END IF;
END $$;
CREATE EXTENSION IF NOT EXISTS pgcrypto;