2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01: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:
Fabien O'Carroll 2019-08-02 10:59:49 +08:00
parent 2c81d7c914
commit 1096dc2085

View file

@ -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);
});
}