Skip to content

Commit

Permalink
remove userId on Mention (#5762)
Browse files Browse the repository at this point in the history
* Remove userId relation on mention

* migration
  • Loading branch information
spolu authored Jun 20, 2024
1 parent 19c4c20 commit 9175118
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 20 deletions.
7 changes: 0 additions & 7 deletions front/lib/api/assistant/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 0 additions & 13 deletions front/lib/models/assistant/conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,11 +547,9 @@ export class Mention extends Model<
declare updatedAt: CreationOptional<Date>;

declare messageId: ForeignKey<Message["id"]>;
declare userId: ForeignKey<User["id"]> | null;
declare agentConfigurationId: string | null; // Not a relation as global agents are not in the DB

declare message: NonAttribute<Message>;
declare user?: NonAttribute<User>;
}

Mention.init(
Expand Down Expand Up @@ -586,10 +584,6 @@ Mention.init(
{
fields: ["agentConfigurationId", "createdAt"],
},
{
fields: ["userId"],
concurrently: true,
},
],
}
);
Expand All @@ -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
});
2 changes: 2 additions & 0 deletions front/migrations/db/migration_23.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Migration created on Jun 20, 2024
ALTER TABLE "public"."mentions" DROP COLUMN "userId";

0 comments on commit 9175118

Please sign in to comment.