我发现在迁移文件中,我们可以用两种方式编写knex迁移。
或者
哪种方法是正确的?
exports.up = function (knex) {
return knex.schema
.createTableIfNotExists('foo', function (table) {
table.increments('id').unique();
table.string('foo1');
table.string('foo2');
})
.createTableIfNotExists('bar', function (table) {
table.increments('bar1');
table.string('bar2').index();
});
或者
exports.up = function (knex) {
return Promise.all([
knex.schema.createTableIfNotExists('foo', function (table) {
table.increments('id').unique();
table.string('foo1');
table.string('foo2');
}),
knex.schema.createTableIfNotExists('bar', function (table) {
table.increments('bar1');
table.string('bar2').index();
})
]);
}
哪种方法是正确的?