Sequelize数据库迁移问题

时间:2019-12-23 06:44:25

标签: node.js express sequelize.js

我正在使用节点,在我运行sequelize db时表达并确定其位置:migrate出现以下问题,

Sequelize CLI [Node: 13.2.0, CLI: 5.5.1, ORM: 5.21.2]

Loaded configuration file "server/config/config.json".

ERROR: Dialect needs to be explicitly supplied as of v4.0.0

用于数据库身份验证的配置文件是

{
  "dev": {
    "username": "user_1",
      "password": "pass",
      "database": "todos_dev",
      "host": "127.0.0.1",
      "dialect": "postgres",
      "operatorsAliases": false
  },
  "test": {
    "username": "root",
    "password": null,
    "database": "database_test",
    "host": "127.0.0.1",
    "dialect": "postgres",
    "operatorsAliases": false,
    "dialectOptions": {
      "bigNumberStrings": true
    }
  },
  "production": {
    "username": "root",
    "password": null,
    "database": "database_production",
    "host": "127.0.0.1",
    "dialect": "postgres",
    "operatorsAliases": false
  }
}

Roles and permissions available in db

1 个答案:

答案 0 :(得分:0)

sequlize无法获得 NODE_ENV ,这意味着它无法决定应使用哪个身份验证详细信息,您需要使用

进行定义
export NODE_ENV=development

或者当您配置数据库连接时,可以将其检查为-

const env = process.env.NODE_ENV || 'development';

这将解决问题。