我正在尝试将mysql数据库迁移到heroku cleardb中。我正在做节点服务。
我尝试的代码是,
knexfile.js
production: {
client: "mysql",
connection: {
host: "us-cdbr-iron-east-04.cleardb.net",
user: "bcf521a*******",
password: "9282****",
database: "heroku_9c9d767dbb*****"
}
}
在 Heroku 中,使用 CLEARDB_DATABASE_URL.it 完成设置配置。当我尝试跑步时
heroku run node_modules/.bin/knex migrate:latest
Running node_modules/.bin/knex migrate:latest on ⬢ hidden-taiga-65640
... up, run.7007 (Free)
Using environment: production
终端错误显示,
knex: Required configuration option 'client' is missing
如何解决这个问题?
仔细检查一下你的环境变量。确保这些与 Heroku 应用设置中的变量匹配。另外,在您的 knexfile 上,请确保您没有使用 ||要声明您的环境,请执行以下操作:
const environment = process.env.ENV || 'development';
只需离开进程.env.ENV。