nsarrazin commited on
Commit
29e4d49
·
1 Parent(s): 8721290

feat: add migration to update reports with assistantId to use contentId

Browse files
src/lib/migrations/routines/10-update-reports-assistantid.ts ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { collections } from "$lib/server/database";
2
+ import type { Migration } from ".";
3
+ import { ObjectId } from "mongodb";
4
+
5
+ const migration: Migration = {
6
+ _id: new ObjectId("000000000000000000000010"),
7
+ name: "Update reports with assistantId to use contentId",
8
+ up: async () => {
9
+ await collections.reports.updateMany(
10
+ {
11
+ assistantId: { $exists: true, $ne: null },
12
+ },
13
+ [
14
+ {
15
+ $set: {
16
+ object: "assistant",
17
+ contentId: "$assistantId",
18
+ },
19
+ },
20
+ {
21
+ $unset: "assistantId",
22
+ },
23
+ ]
24
+ );
25
+ return true;
26
+ },
27
+ };
28
+
29
+ export default migration;
src/lib/migrations/routines/index.ts CHANGED
@@ -10,6 +10,8 @@ import trimMessageUpdates from "./06-trim-message-updates";
10
  import resetTools from "./07-reset-tools-in-settings";
11
  import updateFeaturedToReview from "./08-update-featured-to-review";
12
  import deleteEmptyConversations from "./09-delete-empty-conversations";
 
 
13
  export interface Migration {
14
  _id: ObjectId;
15
  name: string;
@@ -30,4 +32,5 @@ export const migrations: Migration[] = [
30
  resetTools,
31
  updateFeaturedToReview,
32
  deleteEmptyConversations,
 
33
  ];
 
10
  import resetTools from "./07-reset-tools-in-settings";
11
  import updateFeaturedToReview from "./08-update-featured-to-review";
12
  import deleteEmptyConversations from "./09-delete-empty-conversations";
13
+ import updateReportsAssistantId from "./10-update-reports-assistantid";
14
+
15
  export interface Migration {
16
  _id: ObjectId;
17
  name: string;
 
32
  resetTools,
33
  updateFeaturedToReview,
34
  deleteEmptyConversations,
35
+ updateReportsAssistantId,
36
  ];