Skip to content

Latest commit

 

History

History
31 lines (27 loc) · 1.16 KB

MigrationGuideToVersion6_7_0AndUpper.md

File metadata and controls

31 lines (27 loc) · 1.16 KB

Migration guide from version 6.0.0-6.3.5 to version 6.7.x

Started from version 6.7.0 library has 2 big changes:

  • MongoRole and MongoUser use native MongoBD ObjectId type instead of string.
  • MongoRole has new property Claims.

According to changes you need to do 2 updates:

  1. update "_id" from "5e88749c85924566b02855cd" to ObjectId("5e88749c85924566b02855cd") in Users and Roles collections
  2. add empty array to Roles collection

Lower you can find simple scripts to do this updates.
NOTE!: Before do anything please dump your data.

db.Users.find({_id : {$type : 2}}). //find all _id prop with type string 
    forEach(function(item){
        var oldId = item._id;
        var id = ObjectId(oldId); //_id to ObjectId  
        item._id = id; 
        db.Users.insert(item);
        db.Users.remove({ _id : oldId });
        }
    )

Then run this script for Roles collection. Simple change Users => Roles (3 places)
MongoDB types

db.Roles.updateMany({}, {$set : {Claims : []}})