Files
evig/scripts/db/migrations/120_blog_admin_manageable.sql
Mao NakamotoandClaude Opus 4.8 5b4dc37a4a feat(blog): make every post editable & deletable from admin (no git)
Staff can now manage git/file-authored posts from the admin UI without touching
the repo:
- 'Edit' imports the file post into blog_posts (DB wins on slug in the merged
  reader) and opens the normal editor.
- 'Delete' hides the slug via blog_hidden_slugs; public readers + the admin list
  skip it (the markdown stays in the repo as a harmless fallback).
- blog_posts gains a visibility column (public|unlisted); the DB reader + admin
  list now report it instead of hardcoding 'public'. (migration 120)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-10 09:47:21 +02:00

21 lines
1013 B
SQL

-- Migration 120: make every blog post admin-manageable
--
-- Two additions so staff can edit/delete ANY post from the admin UI (including
-- the git/file-authored ones) without touching git:
--
-- 1. blog_posts.visibility — so DB-authored posts can be public or unlisted
-- (matches the file frontmatter `visibility`). Validated at the app layer.
-- 2. blog_hidden_slugs — a suppression list. "Deleting" a git/file post can't
-- remove the markdown at runtime, so instead its slug is hidden here and the
-- public readers skip it (the file stays in the repo as a harmless fallback).
-- Editing a file post imports it into blog_posts (DB wins on slug); this table
-- is only for the delete case.
ALTER TABLE blog_posts ADD COLUMN IF NOT EXISTS visibility text NOT NULL DEFAULT 'public';
CREATE TABLE IF NOT EXISTS blog_hidden_slugs (
slug text PRIMARY KEY,
hidden_by uuid REFERENCES users(id) ON DELETE SET NULL,
created_at timestamptz NOT NULL DEFAULT now()
);