From 9175118cfb46f6ee536de70f686aa453cab6b1c7 Mon Sep 17 00:00:00 2001 From: Stanislas Polu Date: Thu, 20 Jun 2024 15:15:21 +0200 Subject: [PATCH] remove userId on Mention (#5762) * Remove userId relation on mention * migration --- front/lib/api/assistant/messages.ts | 7 ------- front/lib/models/assistant/conversation.ts | 13 ------------- front/migrations/db/migration_23.sql | 2 ++ 3 files changed, 2 insertions(+), 20 deletions(-) create mode 100644 front/migrations/db/migration_23.sql diff --git a/front/lib/api/assistant/messages.ts b/front/lib/api/assistant/messages.ts index e9c3761a5d0f..a1105c388f52 100644 --- a/front/lib/api/assistant/messages.ts +++ b/front/lib/api/assistant/messages.ts @@ -46,13 +46,6 @@ export async function batchRenderUserMessages( where: { messageId: userMessages.map((m) => m.id), }, - include: [ - { - model: User, - as: "user", - required: false, - }, - ], }), (async () => { const userIds = userMessages diff --git a/front/lib/models/assistant/conversation.ts b/front/lib/models/assistant/conversation.ts index 8c59535adb82..37da982a2589 100644 --- a/front/lib/models/assistant/conversation.ts +++ b/front/lib/models/assistant/conversation.ts @@ -547,11 +547,9 @@ export class Mention extends Model< declare updatedAt: CreationOptional; declare messageId: ForeignKey; - declare userId: ForeignKey | null; declare agentConfigurationId: string | null; // Not a relation as global agents are not in the DB declare message: NonAttribute; - declare user?: NonAttribute; } Mention.init( @@ -586,10 +584,6 @@ Mention.init( { fields: ["agentConfigurationId", "createdAt"], }, - { - fields: ["userId"], - concurrently: true, - }, ], } ); @@ -601,10 +595,3 @@ Message.hasMany(Mention, { Mention.belongsTo(Message, { foreignKey: { name: "messageId", allowNull: false }, }); - -User.hasMany(Mention, { - foreignKey: { name: "userId", allowNull: true }, // null = mention is not a user mention -}); -Mention.belongsTo(User, { - foreignKey: { name: "userId", allowNull: true }, // null = mention is not a user mention -}); diff --git a/front/migrations/db/migration_23.sql b/front/migrations/db/migration_23.sql new file mode 100644 index 000000000000..90eca6aca7bf --- /dev/null +++ b/front/migrations/db/migration_23.sql @@ -0,0 +1,2 @@ +-- Migration created on Jun 20, 2024 +ALTER TABLE "public"."mentions" DROP COLUMN "userId";