The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rocket.Chat/server/startup/migrations/v200.js

29 lines
735 B

import { Migrations } from '../../../app/migrations';
import { LivechatDepartmentAgents, LivechatDepartment } from '../../../app/models/server';
const updateEnabledProperty = (departmentIds) => {
LivechatDepartment
.find({ _id: { $in: departmentIds } })
.forEach((department) => {
LivechatDepartmentAgents.update({ departmentId: department._id },
{
$set: { departmentEnabled: department.enabled },
},
{
multi: true,
});
});
};
Migrations.add({
version: 200,
up() {
const departmentIds = [...new Set(LivechatDepartmentAgents
.find({}, { fields: { departmentId: 1 } })
.fetch()
.map((departmentAgent) => departmentAgent.departmentId))];
updateEnabledProperty(departmentIds);
},
});