mirror of
https://github.com/bitbaum/evig.git
synced 2026-12-05 05:37:55 +01:00
Adds an `audience` axis to blog posts, orthogonal to the existing `visibility` (discoverability) column: - public — anyone (default; every existing post, via migration default) - team — logged-in staff only (session.user.isStaff) - author — the author (created_by) + super admins only SSOT: enum + labels + parser in src/config/blog.ts; one access helper (src/lib/blog-access.ts, canViewPost/filterViewable) reused at every read surface — index, post page + generateMetadata, RSS, sitemap, comments API. Admin editor gains a "Zugriff" select (config-driven) and the list shows a per-post access badge. Migration 138 is additive (ADD COLUMN ... DEFAULT 'public', no CHECK — app-validated per migration-110 policy). Verified: typecheck, lint, 83 blog tests (incl. new blog-access truth table), lint:umlauts — all green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
10 lines
591 B
SQL
10 lines
591 B
SQL
-- Migration 138: audience access-control axis for blog posts.
|
|
-- ORTHOGONAL to blog_posts.visibility (public|unlisted|link = discoverability).
|
|
-- audience controls WHO may load the post at all:
|
|
-- public — anyone (default; every existing post)
|
|
-- team — logged-in staff only (session.user.isStaff)
|
|
-- author — the author (created_by) + super admins only
|
|
-- App-validated (zod + src/config/blog.ts BLOG_AUDIENCE), no SQL CHECK
|
|
-- (migration-110 policy — hand-synced CHECK lists drift).
|
|
ALTER TABLE blog_posts ADD COLUMN IF NOT EXISTS audience text NOT NULL DEFAULT 'public';
|