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

23 lines
579 B

import { Migrations } from '../../../app/migrations';
import { Users } from '../../../app/models';
import { generateUsernameSuggestion } from '../../../app/lib';
Migrations.add({
version: 1,
up() {
return Users.find({
username: {
$exists: false,
},
lastLogin: {
$exists: true,
},
}).forEach((user) => {
const username = generateUsernameSuggestion(user);
if (username && username.trim() !== '') {
return Users.setUsername(user._id, username);
}
return console.log('User without username', JSON.stringify(user, null, ' '));
});
},
});