I have to add a column named tid in table “posts”
posts: {
id: {type: ‘string’, maxlength: 24, nullable: false, primary: true},
uuid: {type: ‘string’, maxlength: 36, nullable: false, validations: {isUUID: true}},
…
twitter_description: {type: ‘string’, maxlength: 500, nullable: true},
custom_template: {type: ‘string’, maxlength: 100, nullable: true},
canonical_url: {type: ‘text’, maxlength: 2000, nullable: true},
postid: {type: ‘text’, maxlength: 30, nullable: true}
}
and i wrote the migration/versions/2.23 folder file name as 1-posts-add-tid.js
and wrote the migration as follows:
const Promise = require(‘bluebird’),
common = require(’…/…/…/…/lib/common’),
commands = require(’…/…/…/schema’).commands,
table = ‘posts’,
columns = [‘tid’],
_private = {};_private.handle = function handle(options) {
let type = options.type,
isAdding = type === ‘Adding’,
operation = isAdding ? commands.addColumn : commands.dropColumn;return function (options) {
let connection = options.connection;
return connection.schema.hasTable(table)
.then(function (exists) {
if (!exists) {
return Promise.reject(new Error('Table does not exist!'));
}
return Promise.each(columns, function (column) {
return connection.schema.hasColumn(table, column)
.then(function (exists) {
if (exists && isAdding || !exists && !isAdding) {
common.logging.warn(`${type} column ${table}.${column}`);
return Promise.resolve();
}
common.logging.info(`${type} column ${table}.${column}`);
return operation(table, column, connection);
});
});
});
};
}; module.exports.up = _private.handle({type: ‘Adding’}); module.exports.down = _private.handle({type: ‘Dropping’});
but i am getting following error:
The
ghost run
command is used by the configured Ghost process manager and for debugging. If you’re not running this to debug something, you should runghost start
instead.
[2019-05-08 05:34:19] WARN knex-migrator is skipping 2.23
[2019-05-08 05:34:19] WARN Current version in MigratorConfig.js is smaller then requested version, use --force to proceed!
[2019-05-08 05:34:19] WARN Please runknex-migrator migrate --v 2.23 --force
to proceed!
Unhandled rejection Error: ER_BAD_FIELD_ERROR: Unknown column ‘postid’ in ‘field list’
at Query.Sequence._packetToError (/home/adil/projects/finalsuperone/superone-ghost/versions/2.22.0/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
at Query.ErrorPacket (/home/adil/projects/finalsuperone/superone-ghost/versions/2.22.0/node_modules/mysql/lib/protocol/sequences/Query.js:77:18)