mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-01 01:29:31 +08:00
fix(server): embedding chunks primary key (#12416)
fix AI-131 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Updated database schema to consolidate unique constraints into composite primary keys for embedding-related data, improving consistency. - Changed the relation in the Snapshot model to allow multiple embeddings. - Improved filtering logic for documents and snapshots based on embedding existence. - Reformatted SQL queries and schema attributes for improved readability; no changes to functionality. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
+20
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- The primary key for the `ai_workspace_embeddings` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
- The primary key for the `ai_workspace_file_embeddings` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
|
||||
*/
|
||||
-- DropIndex
|
||||
DROP INDEX "ai_workspace_embeddings_workspace_id_doc_id_chunk_key";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "ai_workspace_file_embeddings_workspace_id_file_id_chunk_key";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "ai_workspace_embeddings" DROP CONSTRAINT "ai_workspace_embeddings_pkey",
|
||||
ADD CONSTRAINT "ai_workspace_embeddings_pkey" PRIMARY KEY ("workspace_id", "doc_id", "chunk");
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "ai_workspace_file_embeddings" DROP CONSTRAINT "ai_workspace_file_embeddings_pkey",
|
||||
ADD CONSTRAINT "ai_workspace_file_embeddings_pkey" PRIMARY KEY ("workspace_id", "file_id", "chunk");
|
||||
Reference in New Issue
Block a user