Skip to content
Permalink
Browse files
馃悰 Fixed migrating from < 1.13 to 1.21
no issue

- discovered while testing
- the fixture utility needed a protection against non existent roles in the database
  - it tries to fetch the contributor role from the database, which does not exist yet
  • Loading branch information
kirrg001 committed Feb 7, 2018
1 parent a8ac58b commit ed4fde4f006281c48880ff24ba997dc83b097bdd
Showing with 9 additions and 0 deletions.
  1. +9 鈭0 core/server/data/schema/fixtures/utils.js
@@ -2,6 +2,7 @@
// Standalone file which can be required to help with advanced operations on the fixtures.json file
var _ = require('lodash'),
Promise = require('bluebird'),
common = require('../../../lib/common'),
models = require('../../../models'),
baseUtils = require('../../../models/base/utils'),
sequence = require('../../../lib/promise/sequence'),
@@ -140,6 +141,14 @@ addFixturesForRelation = function addFixturesForRelation(relationFixture, option
_.each(relationFixture.entries, function processEntries(entry, key) {
var fromItem = data.from.find(matchFunc(relationFixture.from.match, key));

// CASE: You add new fixtures e.g. a new role in a new release.
// As soon as an **older** migration script wants to add permissions for any resource, it iterates over the
// permissions for each role. But if the role does not exist yet, it won't find the matching db entry and breaks.
if (!fromItem) {
common.logging.warn('Skip: Target database entry not found for key: ' + key);
return Promise.resolve();
}

_.each(entry, function processEntryValues(value, key) {
var toItems = data.to.filter(matchFunc(relationFixture.to.match, key, value));
max += toItems.length;

0 comments on commit ed4fde4

Please sign in to comment.