mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Added ability to pass columnSpec to addTableColumn
refs #10922 This gives us the ability to add columns that have since been removed from the schema, for example in a down migration.
This commit is contained in:
parent
2c81d7c914
commit
1096dc2085
1 changed files with 4 additions and 5 deletions
|
@ -5,9 +5,8 @@ var _ = require('lodash'),
|
|||
schema = require('./schema'),
|
||||
clients = require('./clients');
|
||||
|
||||
function addTableColumn(tableName, table, columnName) {
|
||||
var column,
|
||||
columnSpec = schema[tableName][columnName];
|
||||
function addTableColumn(tableName, table, columnName, columnSpec = schema[tableName][columnName]) {
|
||||
var column;
|
||||
|
||||
// creation distinguishes between text with fieldtype, string with maxlength and all others
|
||||
if (columnSpec.type === 'text' && Object.prototype.hasOwnProperty.call(columnSpec, 'fieldtype')) {
|
||||
|
@ -48,9 +47,9 @@ function addTableColumn(tableName, table, columnName) {
|
|||
}
|
||||
}
|
||||
|
||||
function addColumn(tableName, column, transaction) {
|
||||
function addColumn(tableName, column, transaction, columnSpec) {
|
||||
return (transaction || db.knex).schema.table(tableName, function (table) {
|
||||
addTableColumn(tableName, table, column);
|
||||
addTableColumn(tableName, table, column, columnSpec);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue