【发布时间】:2015-10-23 16:22:10
【问题描述】:
使用 postgreSQL db 设置 node.js 应用程序,所有工作在生产环境中。
我使用了成功的 CLI heroku pg:pull ...。我在本地运行 postgres 9.4.X,但是在本地启动我的应用程序(工头启动)时出现错误:“错误错误:关系“test_table”不存在”。我已按照此处的说明进行操作:https://devcenter.heroku.com/articles/heroku-postgresql#local-setup 但在本地运行时我似乎仍然无法访问我的数据库。
bash_profile:
export PATH="/usr/local/heroku/bin:$PATH"
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin
export PATH="/Applications/Postgres93.app/Contents/MacOS/bin:$PATH:$PATH"
控制台错误日志:
15:39:48 web.1 | started with pid 18779
15:39:48 web.1 | Node app is running on port 5000
15:39:52 web.1 | { [error: relation "test_table" does not exist]
15:39:52 web.1 | name: 'error',
15:39:52 web.1 | length: 101,
15:39:52 web.1 | severity: 'ERROR',
15:39:52 web.1 | code: '42P01',
15:39:52 web.1 | detail: undefined,
15:39:52 web.1 | hint: undefined,
15:39:52 web.1 | position: '15',
15:39:52 web.1 | internalPosition: undefined,
15:39:52 web.1 | internalQuery: undefined,
15:39:52 web.1 | where: undefined,
15:39:52 web.1 | schema: undefined,
15:39:52 web.1 | table: undefined,
15:39:52 web.1 | column: undefined,
15:39:52 web.1 | dataType: undefined,
15:39:52 web.1 | constraint: undefined,
15:39:52 web.1 | file: 'parse_relation.c',
15:39:52 web.1 | line: '986',
15:39:52 web.1 | routine: 'parserOpenTable' }
【问题讨论】:
-
创建
test_table?数据库是如何使用模式播种/导入/设置的? -
您可能连接到错误的数据库。您能否显示您的应用程序配置使用的连接字符串,以及您使用的完整 pg:pull 命令?另外,如果你使用 postgresql 'psql' 命令连接到数据库,那么你能看到表吗?
-
pg.connect(process.env.DATABASE_URL, function(err, client, done){.....我不记得我使用的确切 pg:pull,但我应该使用什么来确保它有效?本地 psql \conninfo 是You are connected to database "Oliver" as user "Oliver" via socket in "/tmp" at port "5432".
标签: javascript ruby-on-rails node.js postgresql heroku