Files
evig/scripts/db/migrations/119_blog_comments.sql
Mao NakamotoandClaude Opus 4.8 d3d7338231 feat(blog): comments — any logged-in user can comment
New blog_comments table (migration 119) keyed by post SLUG so it works for
both DB- and git/file-authored posts. Public GET; auth-gated POST (2–2000
chars); author or staff can delete. Comment thread + composer render on every
post page (login prompt when logged out). UI strings translated in all 8 locales.

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

21 lines
1009 B
SQL

-- Migration 119: blog comments
--
-- Any logged-in user can comment on a blog post. Comments are keyed by the post
-- SLUG (not a blog_posts.id) so they work for both DB-authored and git/file
-- posts, and survive a post moving between the two stores. Visible immediately;
-- admins (or the author) can delete. `status` is validated at the app layer
-- (config + zod), not a SQL CHECK, per the migration-110 policy.
CREATE TABLE IF NOT EXISTS blog_comments (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
post_slug text NOT NULL,
user_id uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE,
body text NOT NULL,
status text NOT NULL DEFAULT 'visible',
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS blog_comments_post_slug_idx ON blog_comments (post_slug, created_at);
CREATE INDEX IF NOT EXISTS blog_comments_user_id_idx ON blog_comments (user_id);