mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Added migrations for email settings
no issue
This commit is contained in:
parent
f2f9073edd
commit
2ac2975178
2 changed files with 27 additions and 21 deletions
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
};
|
Loading…
Add table
Reference in a new issue