This is easy to do with SQL but I need to write a Knex migration script which I am not familiar with. The following adds the order_id
column at the end of the row in the order
table. I want order_id
to be added after id
. How do I do that?
const TABLE_NAME = 'order';
exports.up = function (knex) {
return knex.schema.alterTable(TABLE_NAME, table => {
table
.specificType('order_id', 'char(10)')
.unique()
.notNullable();
});
};
exports.down = function (knex) {
return knex.schema.table(TABLE_NAME, function (t) {
t.dropColumn('order_id');
});
};