File size: 579 Bytes
fc69895
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { collections } from "$lib/server/database";
import type { Migration } from ".";
import { ObjectId } from "mongodb";

const migration: Migration = {
	_id: new ObjectId("000000000000000000000010"),
	name: "Update reports with assistantId to use contentId",
	up: async () => {
		await collections.reports.updateMany(
			{
				assistantId: { $exists: true, $ne: null },
			},
			[
				{
					$set: {
						object: "assistant",
						contentId: "$assistantId",
					},
				},
				{
					$unset: "assistantId",
				},
			]
		);
		return true;
	},
};

export default migration;