问题
I was trying to push my rails project database to heroku's database.
I type this
heroku pg:push ReadingList_development DATABASE_URL --app calm-eyrie-9110
(ReadingList_development
is my local database name.)
However, it shows this error
sh: psql: command not found
! Heroku client internal error.
! Search for help at: https://help.heroku.com
! Or report a bug at: https://github.com/heroku/heroku/issues/new
Error: psql failed. exit status 32512, output: "" (RuntimeError)
Command: heroku pg:push ReadingList_development DATABASE_URL --app calm-eyrie-9110
Plugins: heroku-legacy-taps
Version: heroku-toolbelt/3.40.6 (x86_64-darwin10.8.0) ruby/1.9.3
Error ID: c131ced7e02d4080a3ff53e27d7bd983
More information in /Users/Coda/.heroku/error.log
And here is error.log
Heroku client internal error.
psql failed. exit status 32512, output: ""
/Users/Coda/.heroku/client/lib/heroku/command/pg.rb:783:in `exec_sql_on_uri'
/Users/Coda/.heroku/client/lib/heroku/helpers/pg_dump_restore.rb:108:in `exec_sql_on_uri'
/Users/Coda/.heroku/client/lib/heroku/helpers/pg_dump_restore.rb:53:in `ensure_remote_db_empty'
/Users/Coda/.heroku/client/lib/heroku/helpers/pg_dump_restore.rb:23:in `prepare'
/Users/Coda/.heroku/client/lib/heroku/helpers/pg_dump_restore.rb:14:in `execute'
/Users/Coda/.heroku/client/lib/heroku/command/pg.rb:371:in `push'
/Users/Coda/.heroku/client/lib/heroku/command.rb:212:in `run'
/Users/Coda/.heroku/client/lib/heroku/cli.rb:27:in `start'
/usr/bin/heroku:24:in `<main>'
Heroku client internal error.
psql failed. exit status 32512, output: ""
/Users/Coda/.heroku/client/lib/heroku/command/pg.rb:783:in `exec_sql_on_uri'
/Users/Coda/.heroku/client/lib/heroku/helpers/pg_dump_restore.rb:108:in `exec_sql_on_uri'
/Users/Coda/.heroku/client/lib/heroku/helpers/pg_dump_restore.rb:53:in `ensure_remote_db_empty'
/Users/Coda/.heroku/client/lib/heroku/helpers/pg_dump_restore.rb:23:in `prepare'
/Users/Coda/.heroku/client/lib/heroku/helpers/pg_dump_restore.rb:14:in `execute'
/Users/Coda/.heroku/client/lib/heroku/command/pg.rb:371:in `push'
/Users/Coda/.heroku/client/lib/heroku/command.rb:212:in `run'
/Users/Coda/.heroku/client/lib/heroku/cli.rb:27:in `start'
/usr/bin/heroku:24:in `<main>'
Heroku client internal error.
psql failed. exit status 32512, output: ""
/Users/Coda/.heroku/client/lib/heroku/command/pg.rb:783:in `exec_sql_on_uri'
/Users/Coda/.heroku/client/lib/heroku/helpers/pg_dump_restore.rb:108:in `exec_sql_on_uri'
/Users/Coda/.heroku/client/lib/heroku/helpers/pg_dump_restore.rb:53:in `ensure_remote_db_empty'
/Users/Coda/.heroku/client/lib/heroku/helpers/pg_dump_restore.rb:23:in `prepare'
/Users/Coda/.heroku/client/lib/heroku/helpers/pg_dump_restore.rb:14:in `execute'
/Users/Coda/.heroku/client/lib/heroku/command/pg.rb:371:in `push'
/Users/Coda/.heroku/client/lib/heroku/command.rb:212:in `run'
/Users/Coda/.heroku/client/lib/heroku/cli.rb:27:in `start'
/usr/bin/heroku:24:in `<main>`
Update
syndax should be like
heroku pg:push mylocaldb HEROKU_POSTGRESQL_MAGENTA --app sushi
I am not sure what mylocaldb
and HEROKU_POSTGRESQL_MAGENTA
should be. When I type this
heroku pg:push mylocaldb HEROKU_POSTGRESQL_MAGENTA --app calm-eyrie-9110
it return
Unknown database: HEROKU_POSTGRESQL_MAGENTA. Valid options are: DATABASE_URL
Does mylocaldb
should be the same name in database.yaml
?
here is my database.yaml
info
default: &default
adapter: postgresql
encoding: unicode
pool: 5
development:
<<: *default
database: ReadingList_development
Furthermore, I type heroku config:get -a calm-eyrie-9110
it return
! Usage: heroku config:get KEY
! Must specify KEY.
回答1:
heroku pg:info
will either give you the color(HEROKU_POSTGRESQL_MAGENTA
) like in the docs, or it will provide something like postgresql-something-12345
Either one of those will suffice in place for the heroku db
来源:https://stackoverflow.com/questions/31751755/push-local-database-data-to-heroku-database