From 332c4b152c49db2fd8f5b17608fadfc4b3e393e0 Mon Sep 17 00:00:00 2001 From: WhereAreBugs Date: Fri, 23 Jan 2026 11:16:54 +0800 Subject: [PATCH] bugfix(conversation):remove unexpected unique index. --- .../storage/database/mgo/conversation.go | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/pkg/common/storage/database/mgo/conversation.go b/pkg/common/storage/database/mgo/conversation.go index e6be4fd4c..b6436e1c8 100644 --- a/pkg/common/storage/database/mgo/conversation.go +++ b/pkg/common/storage/database/mgo/conversation.go @@ -32,19 +32,26 @@ import ( func NewConversationMongo(db *mongo.Database) (*ConversationMgo, error) { coll := db.Collection(database.ConversationName) - _, err := coll.Indexes().CreateMany(context.Background(), []mongo.IndexModel{{ - Keys: bson.D{ - {Key: "owner_user_id", Value: 1}, - {Key: "conversation_id", Value: 1}, + _, err := coll.Indexes().CreateMany(context.Background(), []mongo.IndexModel{ + { + Keys: bson.D{ + {Key: "owner_user_id", Value: 1}, + {Key: "conversation_id", Value: 1}, + }, + Options: options.Index().SetUnique(true), }, - Options: options.Index().SetUnique(true), - }, { - Keys: bson.D{ - {Key: "conversation_id", Value: 1}, + { + Keys: bson.D{ + {Key: "user_id", Value: 1}, + }, + Options: options.Index(), }, - Options: options.Index().SetUnique(true), - }}, - ) + { + Keys: bson.D{ + {Key: "conversation_id", Value: 1}, + }, + }, + }) if err != nil { return nil, errs.Wrap(err) }