mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 10:01:40 -05:00
make migrations more tolerant
This commit is contained in:
parent
f1469a04ae
commit
7e296de31d
1 changed files with 13 additions and 3 deletions
|
@ -531,7 +531,7 @@ var migrationsList = {
|
|||
telescopeUserData[key] = user[key];
|
||||
} else if (user.votes && !!user.votes[key]) { // look for it in user.votes object
|
||||
telescopeUserData[key] = user.votes[key];
|
||||
} else if (user.profile[key]) { // look for it in user.profile object
|
||||
} else if (user.profile && user.profile[key]) { // look for it in user.profile object
|
||||
telescopeUserData[key] = user.profile[key];
|
||||
}
|
||||
|
||||
|
@ -615,6 +615,7 @@ var migrationsList = {
|
|||
// },
|
||||
migrateDisplayName: function () {
|
||||
var i = 0;
|
||||
var displayName;
|
||||
var allUsers = Meteor.users.find({"telescope.displayName": {$exists: false}});
|
||||
console.log('> Found '+allUsers.count()+' users.\n');
|
||||
|
||||
|
@ -622,9 +623,18 @@ var migrationsList = {
|
|||
i++;
|
||||
|
||||
console.log('> Updating user '+user._id+' (' + user.username + ')');
|
||||
var displayName = user.profile.name || user.profile.username || user.username;
|
||||
if (!!user.profile) {
|
||||
displayName = user.profile.name || user.profile.username;
|
||||
} else {
|
||||
displayName = user.username;
|
||||
}
|
||||
|
||||
console.log('name: ', displayName);
|
||||
Meteor.users.update(user._id, {$set: {"telescope.displayName": displayName}});
|
||||
if (!!displayName) {
|
||||
Meteor.users.update(user._id, {$set: {"telescope.displayName": displayName}});
|
||||
} else {
|
||||
"displayName not found :("
|
||||
}
|
||||
});
|
||||
return i;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue