forked from TryGhost/Ghost
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
tamvm
committed
Sep 24, 2019
1 parent
c218e8e
commit b388e1b
Showing
4 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
core/server/data/migrations/versions/2.31/4-add-type-column-to-tag-table.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const common = require('../../../../lib/common'); | ||
const commands = require('../../../schema').commands; | ||
const table = 'tags'; | ||
const newColumnNames = [ | ||
'kind', | ||
]; | ||
|
||
function printResult(operation, columnName) { | ||
return `${operation} column ${columnName} in ${table} table`; | ||
} | ||
|
||
module.exports.up = (options) => { | ||
const connection = options.connection; | ||
return Promise.map(newColumnNames, (newColumnName) => { | ||
return connection.schema.hasColumn(table, newColumnName) | ||
.then((exists) => { | ||
if (exists) { | ||
common.logging.warn(printResult('Adding', newColumnName)); | ||
return; | ||
} | ||
common.logging.info(printResult('Adding', newColumnName)); | ||
return commands.addColumn(table, newColumnName, connection); | ||
}); | ||
}); | ||
}; | ||
|
||
module.exports.down = (options) => { | ||
const connection = options.connection; | ||
return Promise.map(newColumnNames, (newColumnName) => { | ||
return connection.schema.hasColumn(table, newColumnName) | ||
.then((exists) => { | ||
if (!exists) { | ||
common.logging.warn(printResult('Dropping', newColumnName)); | ||
return; | ||
} | ||
common.logging.info(printResult('Dropping', newColumnName)); | ||
return commands.dropColumn(table, newColumnName, connection); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters