【发布时间】:2020-04-13 12:44:08
【问题描述】:
我错误地删除了将列添加到组表的迁移,然后不得不将其重新添加到我的本地数据库中。但是,在生产中,迁移并没有被错误地删除,所以现在它在运行添加的迁移时会抛出错误。
认识到可能有一个更优雅的解决方案,此时,我只想添加一个条件,仅当添加的列不存在时才运行此添加的迁移。
这是当前添加的迁移:
exports.up = function(knex, Promise) {
return knex.schema.table('groups', function(t) {
t.specificType('fulltext', 'tsvector');
t.index('fulltext', null, 'gin');
});
};
exports.down = function(knex, Promise) {
return knex.schema.table('groups', function(t) {
t.dropColumn('fulltext');
t.dropIndex([ 'fulltext' ]);
});
};
【问题讨论】:
标签: database-migration knex.js