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

21 lines
483 B

RocketChat.Migrations.add({
version: 1,
up() {
return RocketChat.models.Users.find({
username: {
$exists: false
},
lastLogin: {
$exists: true
}
}).forEach((user) => {
const username = RocketChat.generateUsernameSuggestion(user);
if (username && username.trim() !== '') {
return RocketChat.models.Users.setUsername(user._id, username);
} else {
9 years ago
return console.log('User without username', JSON.stringify(user, null, ' '));
}
});
}
});