如何使用postgres在heroku服务器上创建新数据库

Jay*_*hri 2 postgresql heroku

我想在Heroku服务器上创建一个PostgreSQL数据库.

我的database.yml

production:
  adapter: postgresql

  encoding: utf8

  database: ddb
  username: postgres

  port: 5432
  password: admin

  host: localhost
Run Code Online (Sandbox Code Playgroud)

当我运行heroku rake db:create它时给我错误:

mydatabase already exists
    (in /disk1/home/slugs/181380_8d7032f_f439-4fe4f5a6-f181-4150-a968-fadcf45f0af5/mnt)
Run Code Online (Sandbox Code Playgroud)

我已经尝试了各种不同的数据库名称,但得到相同的消息.

我该如何解决这个错误?

oma*_*oma 15

heroku在deploy上自动生成database.yml.读取如下:你放在database.yml中的内容并不重要,这对我来说很好,因为我可以将它包含在git中,而不必担心生成db密码.

你可以通过设置ENV ['DATABASE_URL']来选择另一个数据库(使用heroku config:add DATABASE_URL=....)

检查heroku文档 https://devcenter.heroku.com/articles/ruby-support#build-behavior