716f952bb6
- Add database migrations for message base table with indexes for efficient querying - Implement rich content support with attachment, embed, and poll tables - Create social features including reactions, bookmarks, mentions, and read states - Add thread management with participant tracking and resolution capabilities - Include article posts with title, cover image, tags, and engagement metrics - Support scheduled messages, stickers, forwards, and interactive components - Fix UUID defaults and ensure proper uniqueness constraints for drafts - Add gRPC health server for imks and health check client for appks connectivity - Replace non-connectable 0.0.0.0 addresses with localhost in service discovery - Normalize addresses during RPC configuration to handle bind address issues
24 lines
1006 B
PL/PgSQL
24 lines
1006 B
PL/PgSQL
-- Create message_thread before migrations that reference it.
|
|
-- Safe for existing databases because the table may already exist from 004.
|
|
|
|
BEGIN;
|
|
|
|
CREATE TABLE IF NOT EXISTS message_thread (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
channel_id UUID NOT NULL,
|
|
root_message_id UUID NOT NULL REFERENCES message(id) ON DELETE CASCADE,
|
|
created_by UUID NOT NULL,
|
|
replies_count BIGINT NOT NULL DEFAULT 0,
|
|
participants_count BIGINT NOT NULL DEFAULT 0,
|
|
last_reply_message_id UUID NULL REFERENCES message(id) ON DELETE SET NULL,
|
|
last_reply_at TIMESTAMPTZ NULL,
|
|
resolved BOOLEAN NOT NULL DEFAULT FALSE,
|
|
resolved_by UUID NULL,
|
|
resolved_at TIMESTAMPTZ NULL,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
CONSTRAINT uq_message_thread_root UNIQUE (root_message_id)
|
|
);
|
|
|
|
COMMIT;
|