Knex 迁移 dropForeign 不起作用?

Knex migration dropForeign not working?

将最新版本的 Knex.js 与 Postgresql 数据库一起使用。

我有一个更早的迁移,重命名了一些 table。基本上,所有 table 都是复数(所以 devices 而不是 device),现在它们是单数。现在我们决定要删除其中一个重命名的 table。它有另一个 table 的外键。所以我想我应该能够简单地从table(device_group,曾经是devices_groups)中删除外键,然后删除所需的table(设备,曾经是设备)。所以我在下面创建了迁移:

exports.up = function(knex, Promise) {
  return knex.table('device_group', function (table) {
    table.dropForeign('device_id', 'devices_groups_device_id_foreign');
    table.dropColumn('device_id');
  })
  .then(() => {
    return knex.schema.dropTable('device');
  })
  .then(() => {
    return knex.table('device_group', function (table) {
      table.string('device_id');
    });
  });
};

现在,每当我 运行 执行此操作时,我都不会在调试中看到任何关于尝试删除外键的信息。相反,我只收到以下消息。

Knex:warning - migrations failed with error: drop table "device" - cannot drop table device because other objects depend on it

我是不是漏掉了什么明显的东西?它似乎试图在删除外键之前删除 table。

exports.up 函数内的第一行需要是

knex.schema.table()