File size: 764 Bytes
8d88d9b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 type { Migration } from ".";
import { collections } from "$lib/server/database";
import { ObjectId } from "mongodb";
import { logger } from "$lib/server/logger";

const addToolsToSettings: Migration = {
	_id: new ObjectId("5c9c4c4c4c4c4c4c4c4c4c4c"),
	name: "Add empty 'tools' record in settings",
	up: async () => {
		const { settings } = collections;

		// Find all assistants whose modelId is not in modelIds, and update it to use defaultModelId
		await settings.updateMany(
			{
				tools: { $exists: false },
			},
			{ $set: { tools: [] } }
		);

		settings
			.createIndex({ tools: 1 })
			.catch((e) => logger.error(e, "Error creating index during tools migration"));

		return true;
	},
	runEveryTime: false,
};

export default addToolsToSettings;