2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00

Added migrations for email settings

no issue
This commit is contained in:
Rish 2019-11-04 13:22:03 +07:00
parent f2f9073edd
commit 2ac2975178
2 changed files with 27 additions and 21 deletions

View file

@ -1,25 +1,6 @@
const common = require('../../../../lib/common');
const commands = require('../../../schema').commands;
const createLog = type => msg => common.logging[type](msg);
function createColumnMigration({table, column, dbIsInCorrectState, operation, operationVerb}) {
return function columnMigrations({transacting}) {
return transacting.schema.hasColumn(table, column)
.then(dbIsInCorrectState)
.then((isInCorrectState) => {
const log = createLog(isInCorrectState ? 'warn' : 'info');
log(`${operationVerb} ${table}.${column}`);
if (!isInCorrectState) {
return operation(table, column, transacting);
}
});
};
}
module.exports.up = createColumnMigration({
module.exports.up = commands.createColumnMigration({
table: 'posts',
column: 'send_email_when_published',
dbIsInCorrectState(columnExists) {
@ -29,7 +10,7 @@ module.exports.up = createColumnMigration({
operationVerb: 'Adding'
});
module.exports.down = createColumnMigration({
module.exports.down = commands.createColumnMigration({
table: 'posts',
column: 'send_email_when_published',
dbIsInCorrectState(columnExists) {

View file

@ -0,0 +1,25 @@
const commands = require('../../../schema').commands;
module.exports.up = commands.createColumnMigration({
table: 'posts_meta',
column: 'email_subject',
dbIsInCorrectState(columnExists) {
return columnExists === true;
},
operation: commands.addColumn,
operationVerb: 'Adding'
});
module.exports.down = commands.createColumnMigration({
table: 'posts_meta',
column: 'email_subject',
dbIsInCorrectState(columnExists) {
return columnExists === false;
},
operation: commands.dropColumn,
operationVerb: 'Removing'
});
module.exports.config = {
transaction: true
};