节点 运行 迁移超时

Node running migration timeouts

我在 Node 中 运行 迁移,它超时并出现此错误:

Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

这是我的代码

const myList = {
// list of commands
}
exports.up = async (knex) => {
     await Object.values(myList).reduce(async (prev, sp) => {
        await prev;
        return knex.schema.raw(sp);
    }, Promise.resolve());
};

正如我在这里看到的,我正在按照建议解析 Promise。不确定我该如何更改?

Return 承诺链,例如

exports.up = (knex) => 
    Object.values(myList).reduce((prev, sp) =>
        prev.then(() => knex.schema.raw(sp)), Promise.resolve()
    );

或者,如果您愿意,可以使用更长的版本:

exports.up = (knex) => {
    return Object.values(myList).reduce((prev, sp) => {
        return prev.then(() => knex.schema.raw(sp));
    }, Promise.resolve());
};