mirror of
https://github.com/bitbaum/evig.git
synced 2026-12-04 05:07:00 +01:00
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>
21 lines
1009 B
SQL
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);
|