mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
closes #6972, #6574 - run each database version as top level transaction - run migrations in correct order
26 lines
833 B
JavaScript
26 lines
833 B
JavaScript
var Promise = require('bluebird'),
|
|
commands = require('../../schema').commands,
|
|
table = 'posts',
|
|
column = 'mobiledoc',
|
|
message = 'Adding column: ' + table + '.' + column;
|
|
|
|
module.exports = function addMobiledocColumnToPosts(options, logger) {
|
|
var transaction = options.transacting;
|
|
|
|
return transaction.schema.hasTable(table)
|
|
.then(function (exists) {
|
|
if (!exists) {
|
|
return Promise.reject(new Error('Table does not exist!'));
|
|
}
|
|
|
|
return transaction.schema.hasColumn(table, column);
|
|
})
|
|
.then(function (exists) {
|
|
if (!exists) {
|
|
logger.info(message);
|
|
return commands.addColumn(table, column, transaction);
|
|
} else {
|
|
logger.warn(message);
|
|
}
|
|
});
|
|
};
|