gitdataai/lib/migrate/sql/room/channel_article_up_01.sql
zhenyi 779e4eae2f feat(channel): add article feed and composer with room type support
- Add ArticleFeed component for article-based channels
- Implement ArticleComposer with draft persistence
- Add Newspaper icon for article room type
- Update ChannelPage to conditionally render article feed vs message view
- Add article-related API endpoints and models
- Reset thread view when switching rooms
- Add room type check in channel sidebar
- Update CSS to hide scrollbars globally
- Add gRPC message size limit configuration
- Fix git diff tree handling
2026-05-31 03:09:49 +08:00

29 lines
1.1 KiB
SQL

CREATE TABLE IF NOT EXISTS channel_article (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
channel UUID NOT NULL REFERENCES room(id) ON DELETE CASCADE,
author UUID NOT NULL,
title TEXT NOT NULL,
cover_url TEXT,
content TEXT NOT NULL DEFAULT '',
content_type TEXT NOT NULL DEFAULT 'markdown',
summary TEXT,
tags TEXT[] NOT NULL DEFAULT '{}',
is_pinned BOOLEAN NOT NULL DEFAULT FALSE,
view_count BIGINT NOT NULL DEFAULT 0,
like_count BIGINT NOT NULL DEFAULT 0,
comment_count BIGINT NOT NULL DEFAULT 0,
status TEXT NOT NULL DEFAULT 'published',
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
deleted_at TIMESTAMPTZ
);
-- Index for waterfall feed queries: by channel, pinned first, then by created_at desc
CREATE INDEX IF NOT EXISTS idx_channel_article_feed
ON channel_article (channel, is_pinned DESC, created_at DESC)
WHERE deleted_at IS NULL;
-- Index for author lookup
CREATE INDEX IF NOT EXISTS idx_channel_article_author
ON channel_article (author, created_at DESC);