Hen*_*o12 3 heroku database-migration node.js heroku-postgres knex.js
我正在尝试运行我的第一个迁移,它在heroku postgres数据库中创建一个表.
当我尝试运行时,knex migrate:latest --env development我收到错误Error: Unable to acquire a connection.
我试过的事情:
?ssl=true到我在process.env.LISTINGS_DB_URL中存储的连接字符串的末尾,因为我知道这有时需要连接到herokuPGSSLMODE=require我也偶然发现了这篇文章,有人评论说knex不会接受基于环境的密钥.但是,我正在尝试按照本教程进行操作,这表明它确实如此.我还看到了许多其他引用来强化它.
我还要补充一点,我已经能够从我的应用程序和外部客户端连接到数据库.我在尝试运行knex迁移时遇到此错误.
此外,我已经尝试确定如何检查作为连接字符串发送的内容.在查看knex文档时,我会在"如何调试FAQ部分:"下看到If you pass {debug: true} as one of the options in your initialize settings, you can see all of the query calls being made.有人可以帮我指导我的实际操作吗?或者我已经在我的knexfile.js中成功完成了这项工作?
我的knex.js文件:
var environment = process.env.NODE_ENV || 'development';
var config = require('../knexfile.js')[environment];
module.exports = require('knex')(config);
Run Code Online (Sandbox Code Playgroud)
我的knexfile.js:
module.exports = {
development: {
client: 'pg',
connection: process.env.LISTINGS_DB_URL,
migrations: {
directory: __dirname + '/db/migrations'
},
seeds: {
directory: __dirname + '/db/seeds'
},
debug: true
},
staging: {
client: 'postgresql',
connection: {
database: 'my_db',
user: 'username',
password: 'password'
},
pool: {
min: 2,
max: 10
},
migrations: {
tableName: 'knex_migrations'
}
},
production: {
client: 'postgresql',
connection: {
database: 'my_db',
user: 'username',
password: 'password'
},
pool: {
min: 2,
max: 10
},
migrations: {
tableName: 'knex_migrations'
}
}
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5967 次 |
| 最近记录: |