mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-04-08 02:52:39 -05:00
🐛 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
This commit is contained in:
parent
a8ac58be71
commit
ed4fde4f00
1 changed files with 9 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue