WeKnora/migrations/versioned
wizardchen c578fdbad6 fix(im): isolate IM sessions per agent and recover from deleted sessions
Three bugs fixed:

1. Session cross-contamination (#1066): resolveUserSession and
   resolveThreadSession looked up ChannelSession by (platform, user_id,
   chat_id, tenant_id) without agent_id. When the same user talked to
   two bots bound to different agents under the same tenant, they shared
   a session — mixing knowledge base context. Add agent_id to all four
   WHERE clauses and update the DB unique indexes to match.

2. Swapped parameters in resolveThreadSession: the SQL expected
   (chat_id, thread_id) but Go args passed (threadID, msg.ChatID).

3. Orphaned ChannelSession crash (#1046): deleting a session from the
   WeKnora UI soft-deletes it (GORM), but the ChannelSession row
   survives because soft-delete doesn't trigger SQL ON DELETE CASCADE.
   Subsequent IM messages hit "record not found" on GetSession and the
   bot becomes permanently unresponsive. Now detect this case, recycle
   the stale mapping, and transparently create a fresh session.
2026-04-28 20:53:06 +08:00
..
000000_init.down.sql
…
000000_init.up.sql
…
000001_agent.down.sql
…
000001_agent.up.sql
…
000002_embeddings.down.sql
…
000002_embeddings.up.sql
…
000003_chunk_flags.down.sql
…
000003_chunk_flags.up.sql
…
000004_drop_vlm_model_id.down.sql
…
000004_drop_vlm_model_id.up.sql
…
000005_mentioned_items.down.sql
…
000005_mentioned_items.up.sql
…
000006_custom_agents.down.sql
…
000006_custom_agents.up.sql
…
000007_embeddings_tag_id.down.sql
…
000007_embeddings_tag_id.up.sql
…
000008_migrate_untagged_faq.down.sql
…
000008_migrate_untagged_faq.up.sql
…
000009_add_last_faq_import_result.down.sql
…
000009_add_last_faq_import_result.up.sql
…
000010_add_seq_id.down.sql
…
000010_add_seq_id.up.sql
…
000011_pg_search_update.down.sql
…
000011_pg_search_update.up.sql
…
000012_organizations.down.sql
…
000012_organizations.up.sql
…
000013_engine_configs.down.sql
…
000013_engine_configs.up.sql
…
000014_storage_provider_config.down.sql
…
000014_storage_provider_config.up.sql
…
000015_add_is_fallback.down.sql
…
000015_add_is_fallback.up.sql
…
000016_add_kb_pinned.down.sql
…
000016_add_kb_pinned.up.sql
…
000017_mcp_builtin.down.sql
…
000017_mcp_builtin.up.sql
…
000018_extend_tenant_api_key.down.sql
…
000018_extend_tenant_api_key.up.sql
…
000019_add_agent_duration_ms.down.sql
…
000019_add_agent_duration_ms.up.sql
…
000020_add_message_knowledge_id.down.sql
…
000020_add_message_knowledge_id.up.sql
…
000021_im_channel.down.sql
…
000021_im_channel.up.sql
…
000022_message_images.down.sql
…
000022_message_images.up.sql
…
000023_im_channel_kb_id.down.sql
…
000023_im_channel_kb_id.up.sql
…
000024_im_channel_bot_identity.down.sql
…
000024_im_channel_bot_identity.up.sql
…
000025_message_channel.down.sql feat(knowledge): add channel support to knowledge entries and related components 2026-03-25 22:08:29 +08:00
000025_message_channel.up.sql feat(knowledge): add channel support to knowledge entries and related components 2026-03-25 22:08:29 +08:00
000026_chunks_query_indexes.down.sql feat(agent): enhance chunk search functionality to include total chunk counts 2026-03-25 22:08:29 +08:00
000026_chunks_query_indexes.up.sql feat(agent): enhance chunk search functionality to include total chunk counts 2026-03-25 22:08:29 +08:00
000027_message_rendered_content.down.sql feat(prompt): enhance context and intent classification in templates 2026-03-26 18:57:12 +08:00
000027_message_rendered_content.up.sql feat(prompt): enhance context and intent classification in templates 2026-03-26 18:57:12 +08:00
000028_im_thread_session.down.sql [NELO-1102] feat(im): add thread-based session mode for IM channels 2026-03-30 10:43:14 +08:00
000028_im_thread_session.up.sql [NELO-1102] feat(im): add thread-based session mode for IM channels 2026-03-30 10:43:14 +08:00
000029_datasource_tables.down.sql feat(web-search): refactor web search provider 2026-03-31 20:22:34 +08:00
000029_datasource_tables.up.sql fix(migrations): correct migration numbers and remove broken trigger 2026-04-03 11:31:21 +08:00
000030_web_search_providers.down.sql feat(web-search): refactor web search provider 2026-03-31 20:22:34 +08:00
000030_web_search_providers.up.sql fix(migrations): correct migration numbers and remove broken trigger 2026-04-03 11:31:21 +08:00
000031_add_asr_config.down.sql feat(asr): add ASR model connection check and update related components 2026-04-02 21:27:27 +08:00
000031_add_asr_config.up.sql fix(migrations): correct migration numbers and remove broken trigger 2026-04-03 11:31:21 +08:00
000032_vector_stores.down.sql feat: add VectorStore entity, repository, and migrations 2026-04-09 01:39:51 +08:00
000032_vector_stores.up.sql feat: add VectorStore entity, repository, and migrations 2026-04-09 01:39:51 +08:00
000033_add_video_info_to_chunks.down.sql fix: 修正视频相关迁移文件版本号冲突,从 000032 改为 000033 2026-04-10 22:01:42 +08:00
000033_add_video_info_to_chunks.up.sql fix: 修正视频相关迁移文件版本号冲突,从 000032 改为 000033 2026-04-10 22:01:42 +08:00
000034_add_attachments.down.sql fix: rename sql file 2026-04-14 14:54:21 +08:00
000034_add_attachments.up.sql fix: rename sql file 2026-04-14 14:54:21 +08:00
000035_add_credentials.down.sql refactor(weknoracloud): update credential handling and configuration 2026-04-15 11:37:24 +08:00
000035_add_credentials.up.sql refactor(weknoracloud): update credential handling and configuration 2026-04-15 11:37:24 +08:00
000036_kb_vector_store_id.down.sql feat: add vector_store_id column to knowledge_bases for per-KB vector store binding 2026-04-20 19:53:44 +08:00
000036_kb_vector_store_id.up.sql feat: add vector_store_id column to knowledge_bases for per-KB vector store binding 2026-04-20 19:53:44 +08:00
000037_wiki_and_indexing.down.sql feat: Remove outdated wiki and indexing migration files 2026-04-22 21:24:08 +08:00
000037_wiki_and_indexing.up.sql feat: Remove outdated wiki and indexing migration files 2026-04-22 21:24:08 +08:00
000038_im_session_agent_id.down.sql fix(im): isolate IM sessions per agent and recover from deleted sessions 2026-04-28 20:53:06 +08:00
000038_im_session_agent_id.up.sql fix(im): isolate IM sessions per agent and recover from deleted sessions 2026-04-28 20:53:06 +08:00