|
|
@@ -11,6 +11,7 @@ module.exports = {
|
|
|
|
|
|
mongoose.connect(getMongoUri(), mongoOptions);
|
|
|
const pageCollection = await db.collection('pages');
|
|
|
+ const pageOperationCollection = await db.collection('pageoperations');
|
|
|
|
|
|
// Set the model type of grantedGroup to UserGroup
|
|
|
// for Pages that were created before ExternalUserGroup was introduced
|
|
|
@@ -18,6 +19,12 @@ module.exports = {
|
|
|
{ grantedGroupModel: null },
|
|
|
{ $set: { grantedGroupModel: 'UserGroup' } },
|
|
|
);
|
|
|
+ // Set the model type of grantUserGroupIdModel to UserGroup
|
|
|
+ // for PageOperations that were created before ExternalUserGroup was introduced
|
|
|
+ pageOperationCollection.updateMany(
|
|
|
+ { 'options.grantUserGroupIdModel': null },
|
|
|
+ { $set: { 'options.grantUserGroupIdModel': 'UserGroup' } },
|
|
|
+ );
|
|
|
|
|
|
logger.info('Migration has successfully applied');
|
|
|
},
|
|
|
@@ -27,11 +34,16 @@ module.exports = {
|
|
|
|
|
|
mongoose.connect(getMongoUri(), mongoOptions);
|
|
|
const pageCollection = await db.collection('pages');
|
|
|
+ const pageOperationCollection = await db.collection('pageoperations');
|
|
|
|
|
|
pageCollection.updateMany(
|
|
|
{ grantedGroupModel: 'UserGroup' },
|
|
|
{ $set: { grantedGroupModel: null } },
|
|
|
);
|
|
|
+ pageOperationCollection.updateMany(
|
|
|
+ { 'options.grantUserGroupIdModel': 'UserGroup' },
|
|
|
+ { $set: { 'options.grantUserGroupIdModel': null } },
|
|
|
+ );
|
|
|
|
|
|
logger.info('Migration has been successfully rollbacked');
|
|
|
},
|