Skip to content

Commit

Permalink
Allow config option for skipping upgrades
Browse files Browse the repository at this point in the history
Fixes clay#714
  • Loading branch information
elgreg committed Sep 18, 2024
1 parent 083a1b3 commit 0769eff
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/services/upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ function upgradeData(schemaVersion, dataVersion, ref, data, locals) {
* @return {Promise}
*/
function checkForUpgrade(ref, data, locals) {
if (locals && locals.disableUpgrades) {
return bluebird.resolve(data);
}

return utils.getSchema(ref)
.then(schema => {
// If version does not match what's in the data
Expand Down
13 changes: 13 additions & 0 deletions lib/services/upgrade.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,19 @@ describe(_.startCase(filename), function () {
expect(lib.upgradeData.calledOnce).to.be.true;
});
});

it('does not call upgradeData or getSchema if locals.disableUpgrades is true', function () {
let locals = {disableUpgrades: true};

sandbox.stub(lib, 'upgradeData');

return fn('site/_components/foo/instances/bar', {_version: 1, value: 'bar'}, locals)
.then(function () {
expect(lib.upgradeData.calledOnce).to.be.false;
expect(utils.getSchema.calledOnce).to.be.false;
});
});

});

describe('upgradeData', function () {
Expand Down

0 comments on commit 0769eff

Please sign in to comment.