Differences between versions:
MongoUser.Roles
property contains id of role instead of NormalizedNameMongoUser.Claims
has new structure ofClaim
objectMongoRole
has 2 new propertiesClaims
andConcurrencyStamp
.
Lower you can find simple scripts to do necessary updates.
NOTE!: Before do anything please dump your data.
- Users collections:
db.Users.updateMany( {}, { $rename: { "LockoutEndDateUtc": "LockoutEnd" } } )
db.Users.find({}).
forEach(function(item){
// claims processing
var newClaimsArray = [];
item.Claims.forEach(function(claim){
newClaimsArray.push({
"_id" : 0,
"UserId" : null,
"ClaimType" : claim.Type,
"ClaimValue" : claim.Value
});
});
item.Claims = newClaimsArray;
// roles processing
var newRolesArray = [];
item.Roles.forEach(function(role){
var originalRole = db.Roles.findOne({NormalizedName : role});
newRolesArray.push(originalRole._id.str);
});
item.Roles = newRolesArray;
db.Users.save(item);
}
)
- Roles collcetions:
db.Roles.updateMany({}, {$set : {Claims : [], ConcurrencyStamp : ""}})