feat(phase3): threads backend + thread panel UI

This commit is contained in:
2026-06-30 10:36:18 -04:00
parent bd260183ef
commit f3f03df710
9 changed files with 634 additions and 122 deletions
+28
View File
@@ -316,6 +316,34 @@ CREATE TABLE IF NOT EXISTS channel_overrides (
CREATE INDEX IF NOT EXISTS idx_channel_overrides_channel ON channel_overrides(channel_id);
CREATE INDEX IF NOT EXISTS idx_channel_overrides_target ON channel_overrides(channel_id, target_type, target_id);
-- Threads: reuse channels table by adding parent_channel_id; thread messages are still messages scoped to the thread channel.
ALTER TABLE channels ADD COLUMN IF NOT EXISTS parent_channel_id UUID REFERENCES channels(id) ON DELETE CASCADE;
ALTER TABLE channels ADD COLUMN IF NOT EXISTS archived_at TIMESTAMPTZ;
ALTER TABLE channels ADD COLUMN IF NOT EXISTS auto_archive_duration INTEGER NOT NULL DEFAULT 1440;
ALTER TABLE channels ADD COLUMN IF NOT EXISTS message_count INTEGER NOT NULL DEFAULT 0;
ALTER TABLE channels ADD COLUMN IF NOT EXISTS last_message_at TIMESTAMPTZ;
CREATE INDEX IF NOT EXISTS idx_channels_parent ON channels(parent_channel_id);
-- Forum tags
CREATE TABLE IF NOT EXISTS forum_tags (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
channel_id UUID NOT NULL REFERENCES channels(id) ON DELETE CASCADE,
name VARCHAR(64) NOT NULL,
emoji VARCHAR(32),
color VARCHAR(7),
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
UNIQUE (channel_id, name)
);
CREATE INDEX IF NOT EXISTS idx_forum_tags_channel ON forum_tags(channel_id);
-- Thread tag assignments (for forum posts)
CREATE TABLE IF NOT EXISTS channel_tags (
channel_id UUID NOT NULL REFERENCES channels(id) ON DELETE CASCADE,
tag_id UUID NOT NULL REFERENCES forum_tags(id) ON DELETE CASCADE,
PRIMARY KEY (channel_id, tag_id)
);
-- Message full-text search
ALTER TABLE messages ADD COLUMN IF NOT EXISTS search_vector tsvector;
CREATE INDEX IF NOT EXISTS idx_messages_search ON messages USING GIN(search_vector);