将本地PostgreSQL数据库推送到远程Heroku服务器

时间:2014-12-29 04:28:02

标签: postgresql batch-file heroku environment-variables

在Windows 7上,我想将我的本地PostgreSQL数据库(9.4.0)推送到Heroku上的远程PostgreSQL服务器(9.3.3),我跟着Heroku PostgreSQL Document推送:

>heroku pg:push postgres HEROKU_POSTGRESQL_NAVY_URL --app salty-atoll-4222

Your version of git is 1.9.5.. Which has serious security vulnerabilities.
More information here: https://blog.heroku.com/archives/2014/12/23/update_your_git_clients_on_windows_and_os_x
'env' is not recognized as an internal or external command,
operable program or batch file.
Password:
 !    WARNING: Extensions in newly created target database differ from existing source database.
 !
 !    Target extensions:
 !     extname
 !    ---------
 !     plpgsql
 !    (1 row)
 !
 !
 !    Source extensions:
 !      extname
 !    -----------
 !     adminpack
 !     plpgsql
 !    (2 rows)
 !
 !
 !    HINT: You should review output to ensure that any errors
 !    ignored are acceptable - entire tables may have been missed, where a dependency
 !    could not be resolved. You may need to to install a postgresql-contrib package
 !    and retry.

我的本​​地数据库服务器URL为localhost:5432。用户名和数据库名都是postgres,我已将PGUSERPGPASSWORD添加到我的系统变量中,同样,我的DATABASE_URL系统变量为{{1 }}

此外,由于它显示postgres://postgres:password@localhost:5432/postgres,我猜'env' is not recognized as an internal or external command, operable program or batch file.命令可用于替换set,因此我还在env中添加了别名env.bat

C:\Windows\System32\env.bat

但它仍然无法识别@ECHO OFF set 命令和我的env变量,要求我手动输入密码,显示相同的警告,我的数据库无法推送到这个远程服务器。这里的问题是什么?

1 个答案:

答案 0 :(得分:2)

在Windows上,需要在Heroku上对ENV变量进行不同的配置,如果你已经尝试过,我在你的问题中没有看到:

heroku config:set GITHUB_USERNAME=joesmith
Adding config vars and restarting myapp... done, v12
GITHUB_USERNAME: joesmith

$ heroku config
GITHUB_USERNAME: joesmith
OTHER_VAR:    production

$ heroku config:get GITHUB_USERNAME
joesmith

$ heroku config:unset GITHUB_USERNAME
Unsetting GITHUB_USERNAME and restarting myapp... done, v13

可以找到更多相关文档here