Closed lmarini closed 2 years ago
hmm i can't duplicate this on my local though:
this is branching off the latest develop branch
this seems to be related to a migration of the mongo database, and not dropping the table (or starting clowder before import is finished) when importing a mongo dump.
You can see this by running:
db.roles.find().forEach(function(d) { print(d._id + " " + d.name + " " + db.social.users.count({"spaceandrole.role._id": d._id}))})
61301dafe4b0bf6768a4b517 Admin 2
61301dafe4b0bf6768a4b518 Editor 0
61301dafe4b0bf6768a4b519 Viewer 0
5744cb6de4b01f66da43df9a Admin 33
5744cb6de4b01f66da43df9c Viewer 14
5744cb6de4b01f66da43df9b Editor 4
This shows that there are 2 admin roles, one with 2 and one with 33 users. Next step is to merge the two admin roles:
db.social.users.updateOne({"spaceandrole.role._id": ObjectId("61301dafe4b0bf6768a4b517")}, {$set: {"spaceandrole.$.role._id": ObjectId("5744cb6de4b01f66da43df9a")}}, {multi:1})
Running the first query shows it worked:
db.roles.find().forEach(function(d) { print(d._id + " " + d.name + " " + db.social.users.count({"spaceandrole.role._id": d._id}))})
61301dafe4b0bf6768a4b517 Admin 0
61301dafe4b0bf6768a4b518 Editor 0
61301dafe4b0bf6768a4b519 Viewer 0
5744cb6de4b01f66da43df9a Admin 34
5744cb6de4b01f66da43df9c Viewer 14
5744cb6de4b01f66da43df9b Editor 4
finally we can remove the extra roles (i picked the smallest id of the new roles):
db.roles.remove({"_id": {$gte: ObjectId("61301dafe4b0bf6768a4b517")}})
WriteResult({ "nRemoved" : 3 })
Space roles page show categories twice. Seen on v1.19.2 CINET instance
.