顺序迁移无法识别现有表

时间:2018-11-16 03:04:03

标签: sequelize.js sequelize-cli

我正在尝试找出在迁移时将sequelize预先添加到我的SQL查询表名之前的原因public,我认为这与我看到SequelizeDatabaseError: relation "public.organization" does not exist的原因直接相关。 organization是表的名称,因此迁移不应该成为问题,但是public似乎确实是在先挂起并抛出原始SQL的后继。

"sequelize": "^3.19.2",
"sequelize-cli": "2.7.0",

这是迁移文件:

'use strict';

    module.exports = {
      up: function (queryInterface, Sequelize) {
        return queryInterface.addColumn('organization', 'admin_id');
      },

      down: function (queryInterface, Sequelize) {
        return queryInterface.removeColumn('organization', 'admin_id',{
          type: Sequelize.INTEGER,
          before: "admin"
        });
      }
    };

这是错误的截断版本:

  name: 'SequelizeDatabaseError',
  message: 'relation "public.organization" does not exist',
  parent: 
   { error: relation "public.organization" does not exist
...
  sql: 'ALTER TABLE "public"."organization" ADD COLUMN "admin_id" INTEGER;' },

0 个答案:

没有答案