2026-09-16 00:43:04 +02:00
|
|
|
-- AI Assistant plugin migration 0002: chat folders
|
|
|
|
|
-- FIX 2026-09-16: ai_chat_attachments and the folder_id ALTER on
|
|
|
|
|
-- ai_chat_sessions removed — AI chat moved to comm_conversations/
|
|
|
|
|
-- comm_messages (Alembic 0137 dropped the legacy tables). Only the
|
|
|
|
|
-- ai_chat_folders table remains (still used for chat folder ordering).
|
2026-07-17 09:15:39 +02:00
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS ai_chat_folders (
|
|
|
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
|
|
|
name VARCHAR(255) NOT NULL,
|
|
|
|
|
parent_id UUID REFERENCES ai_chat_folders(id) ON DELETE CASCADE,
|
|
|
|
|
user_id UUID NOT NULL,
|
|
|
|
|
tenant_id UUID NOT NULL,
|
|
|
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
|
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
|
|
|
deleted_at TIMESTAMPTZ
|
|
|
|
|
);
|
|
|
|
|
CREATE INDEX IF NOT EXISTS ix_ai_folders_user ON ai_chat_folders(user_id);
|
|
|
|
|
CREATE INDEX IF NOT EXISTS ix_ai_folders_tenant ON ai_chat_folders(tenant_id);
|
|
|
|
|
CREATE INDEX IF NOT EXISTS ix_ai_folders_parent ON ai_chat_folders(parent_id);
|