Spaces:
Sleeping
Sleeping
File size: 814 Bytes
d922910 725337f d922910 725337f d922910 |
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 31 32 33 34 35 36 37 |
import type { Migration } from ".";
import { collections } from "$lib/server/database";
import { DEFAULT_PERSONAS } from "$lib/server/defaultPersonas";
import { ObjectId } from "mongodb";
const migration: Migration = {
_id: new ObjectId("000000000000000000000011"),
name: "Add personas to settings",
up: async () => {
const { settings } = collections;
// Add personas array and activePersonas to all existing settings
await settings.updateMany(
{},
{
$set: {
activePersonas: ["default"],
personas: DEFAULT_PERSONAS.map((p) => ({
...p,
createdAt: new Date(),
updatedAt: new Date(),
})),
updatedAt: new Date(),
},
// Remove customPrompts field
$unset: {
customPrompts: "",
},
}
);
return true;
},
};
export default migration;
|