Meteor-Community-Packages / meteor-roles

Authorization package for Meteor, compatible with built-in accounts packages
http://meteor-community-packages.github.io/meteor-roles/
MIT License
921 stars 166 forks source link

Migration Script should delete old roles #300

Open leprekon91 opened 4 years ago

leprekon91 commented 4 years ago

The migration scripts do not delete the old roles in the Roles collection:

{ "_id" : "admin", "children" : [ ] } //new role is created
{ "_id" : "u9jJZoAfaEApp6QBw", "name" : "admin" } // old role is still here

Shouldn't the old roles go the way of the dodo?

SimonSimCity commented 4 years ago

This is when updating from v1 to v2?

leprekon91 commented 4 years ago

After running those (one after the other):

Roles._forwardMigrate();
Roles._forwardMigrate2();

so v1 -> v2 and then immediatly v2 -> v3.

SimonSimCity commented 4 years ago

Thanks. As far as I've taken a look at it, this is when updating the database from v1 to v2 ... I've just started using this library in v2 and was quite surprised this could happen 😅

Please let me know if you'll have time to look into the first update script and create a PR - I'm on holiday for about a week but can have a look at it afterwards as my other spare-time activities allow.

SimonSimCity commented 4 years ago

I've looked a bit into the update-script for another issue on this project and I do not see a reason to leave the old roles around. Still - I want to test it back and forth before removing them in the update-script. Everyone else is welcome to kick them out and provide some feedback here.

Specially helpful would it be if someone on a bigger codebase could share his experience on a forward and backward migration on 1.x to 2.x.