mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
24 lines
745 B
JavaScript
24 lines
745 B
JavaScript
|
var _ = require('lodash'),
|
||
|
models = require('../../../models'),
|
||
|
errors = require('../../../errors'),
|
||
|
versioning = require('../../schema/versioning');
|
||
|
|
||
|
// @TODO: models.init
|
||
|
module.exports = function insertSettings(options) {
|
||
|
var localOptions = _.merge({context: {internal: true}}, options);
|
||
|
|
||
|
models.init();
|
||
|
|
||
|
return models.Settings.populateDefaults(localOptions)
|
||
|
.then(function () {
|
||
|
return versioning.getDatabaseVersion(localOptions);
|
||
|
})
|
||
|
.catch(function (err) {
|
||
|
if (err instanceof errors.DatabaseVersionError && err.code === 'VERSION_DOES_NOT_EXIST') {
|
||
|
return versioning.setDatabaseVersion(localOptions);
|
||
|
}
|
||
|
|
||
|
throw err;
|
||
|
});
|
||
|
};
|