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/v113.js

34 lines
659 B

import { Migrations } from '../../../app/migrations';
import { Uploads, Messages } from '../../../app/models';
Migrations.add({
version: 113,
up() {
if (Uploads && Messages) {
const fileQuery = {
userId: null,
};
const filesToUpdate = Uploads.find(fileQuery);
filesToUpdate.forEach((file) => {
const messageQuery = {
'file._id': file._id,
};
const message = Messages.findOne(messageQuery);
if (message) {
const filter = {
_id: file._id,
};
const update = {
$set: {
userId: message.u._id,
},
};
Uploads.model.direct.update(filter, update);
}
});
}
},
});