mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
refs #7489 - new database versioning scheme which is based upon the Ghost version, and so easier to reason about - massive refactor of all the version related code Summary of changes: * ✨ new error: DatabaseNotSeeded * 🎨 change versioning module - versioning is based on Ghost Version * 🎨 change bootUp file - add big picture description - version error get's trigger from versioning module * 🎨 default setting for database version is null - very important change: this is caused by the big picture - see bootUp description - the database version get's set by the seed script later - db version is by default null - 1. population happens (we ensure that this has finished, by checking if each table exists) - 2. seeds happening (we ensure that seeds happend if database version is set to X.X) * 🎨 temporary change for population logic - set database version after population happens - ensure population of default settings happend before - both: get's removed in next iteration * 🎨 adapt tests && mark TODO's * 🎨 err instance checking
37 lines
1.3 KiB
JavaScript
37 lines
1.3 KiB
JavaScript
var Promise = require('bluebird'),
|
|
versioning = require('./versioning'),
|
|
populate = require('../migration/populate'),
|
|
errors = require('./../../errors');
|
|
|
|
module.exports = function bootUp() {
|
|
/**
|
|
* @TODO:
|
|
* - 1. call is check if tables are populated
|
|
* - 2. call is check if db is seeded
|
|
*
|
|
* These are the calls Ghost will make to find out if the db is in OK state!
|
|
* These check's will have nothing to do with the migration module!
|
|
* Ghost will not touch the migration module at all.
|
|
*
|
|
* Example code:
|
|
* models.Settings.findOne({key: 'databasePopulated'})
|
|
* If not, throw error and tell user what to do (ghost db-init)!
|
|
*
|
|
* versioning.getDatabaseVersion() - not sure about that yet.
|
|
* This will read the database version of the settings table!
|
|
* If not, throw error and tell user what to do (ghost db-seed)!
|
|
*
|
|
* @TODO:
|
|
* - remove return populate() -> belongs to db init
|
|
* - key: migrations-kate
|
|
*/
|
|
return versioning
|
|
.getDatabaseVersion()
|
|
.catch(function errorHandler(err) {
|
|
if (err instanceof errors.DatabaseNotPopulatedError) {
|
|
return populate();
|
|
}
|
|
|
|
return Promise.reject(err);
|
|
});
|
|
};
|