feat(im): add file support and knowledge base integration
This commit is contained in:
@@ -0,0 +1 @@
|
||||
ALTER TABLE im_channels DROP COLUMN IF EXISTS knowledge_base_id;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- Add knowledge_base_id column to im_channels table.
|
||||
-- When set, file messages received on this channel will be saved to the specified knowledge base.
|
||||
ALTER TABLE im_channels ADD COLUMN IF NOT EXISTS knowledge_base_id VARCHAR(36) DEFAULT '';
|
||||
@@ -0,0 +1,2 @@
|
||||
DROP INDEX IF EXISTS idx_im_channels_bot_identity;
|
||||
ALTER TABLE im_channels DROP COLUMN IF EXISTS bot_identity;
|
||||
@@ -0,0 +1,17 @@
|
||||
-- Migration: 000024_im_channel_bot_identity
|
||||
-- Description: Add bot_identity column to im_channels for duplicate bot prevention.
|
||||
-- bot_identity is a computed unique key derived from credentials, ensuring each bot
|
||||
-- can only be connected to one active (non-deleted) channel.
|
||||
DO $$ BEGIN RAISE NOTICE '[Migration 000024] Adding bot_identity column to im_channels'; END $$;
|
||||
|
||||
ALTER TABLE im_channels ADD COLUMN IF NOT EXISTS bot_identity VARCHAR(255) NOT NULL DEFAULT '';
|
||||
|
||||
-- Partial unique index: only enforce uniqueness for non-deleted rows with a non-empty bot_identity.
|
||||
-- Empty bot_identity (unknown credential format) is excluded from the constraint.
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_im_channels_bot_identity
|
||||
ON im_channels (bot_identity)
|
||||
WHERE deleted_at IS NULL AND bot_identity != '';
|
||||
|
||||
COMMENT ON COLUMN im_channels.bot_identity IS 'Unique bot identity derived from credentials (e.g. wecom:ws:{bot_id}, feishu:{app_id}). Used to prevent duplicate bot bindings.';
|
||||
|
||||
DO $$ BEGIN RAISE NOTICE '[Migration 000024] bot_identity column and unique index created successfully'; END $$;
|
||||
Reference in New Issue
Block a user