【发布时间】:2017-03-26 01:42:42
【问题描述】:
我正在尝试让 knex 在我的 node.js 应用程序中工作。我正在关注一个教程,并在某个时候创建了一个表格,但无法重复该过程。我删除了表并删除了所有迁移文件夹。此时我重新开始,但在创建新迁移然后运行knex migrate:latest 后,我收到一条错误消息,指出迁移目录已损坏,因为我的原始迁移丢失了。
我的印象是,如果文件丢失,它不应该知道它曾经在那里。
从我的项目中删除迁移的正确方法是什么?
knexfile.js
development: {
client: 'pg',
connection: {
host: '127.0.0.1',
user: 'postgres',
password: 'password',
database: 'myDatabase'
},
pool: {
min: 10,
max: 20
},
migrations: {
directory: __dirname + '/db/migrations'
},
seeds: {
directory: __dirname + '/db/seeds/development'
}
db.js
var config = require('../knexfile.js');
var env = 'development';
var knex = require('knex')(config[env]);
module.exports = knex;
console.log('Getting knex');
knex.migrate.latest([config]);
console.log('Applying migration...');
运行会报错,
knex migrate:latest
Using environment: development
Error: The migration directory is corrupt, the following files are missing: 20161110130954_auth_level.js
但此迁移不存在,因为我删除了它。
【问题讨论】:
标签: javascript node.js knex.js