mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
869a35c97d
* 🎨 move heart of fixtures to schema folder and change user model - add fixtures.json to schema folder - add fixture utils to schema folder - keep all the logic! --> FIXTURE.JSON - add owner user with roles --> USER MODEL - add password as default - findAll: allow querying inactive users when internal context (defaultFilters) - findOne: do not remove values from original object! - add: do not remove values from original object! * 🔥 remove migrations key from default_settings.json - this was a temporary invention for an older migration script - sephiroth keep alls needed information in a migration collection * 🔥 add code property to errors - add code property to errors - IMPORTANT: please share your opinion about that - this is a copy paste behaviour of how node is doing that (errno, code etc.) - so code specifies a GhostError * 🎨 change error handling in versioning - no need to throw specific database errors anymore (this was just a temporary solution) - now: we are throwing real DatabaseVersionErrors - specified by a code - background: the versioning unit has not idea about seeding and population of the database - it just throws what it knows --> database version does not exist or settings table does not exist * 🎨 sephiroth optimisations - added getPath function to get the path to init scripts and migration scripts - migrationPath is still hardcoded (see TODO) - tidy up database naming to transacting * ✨ migration init scripts are now complete - 1. add tables - 2. add fixtures - 3. add default settings * 🎨 important: make bootup script smaller! - remove all TODO'S except of one - no seeding logic in bootup script anymore 🕵🏻 * ✨ sephiroth: allow params for init command - param: skip (do not run this script) - param: only (only run this script) - very simple way * 🎨 adapt tests and test env - do not use migrate.populate anymore - use sephiroth instead - jscs/jshint * 🎨 fix User model status checks
23 lines
745 B
JavaScript
23 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;
|
|
});
|
|
};
|