Jayashri
Jayashri

Reputation: 4333

How to create new database on heroku server with postgres

I want to create a PostgreSQL database on a Heroku server.

My database.yml is

production:
  adapter: postgresql

  encoding: utf8

  database: ddb
  username: postgres

  port: 5432
  password: admin

  host: localhost

When I run heroku rake db:create it gives me the error:

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

I have tried it for various different database names, but get the same message.

How can I resolve this error?

Upvotes: 2

Views: 15727

Answers (1)

oma
oma

Reputation: 40760

heroku autogenerates database.yml on the deploy. Reads like: it doesn't matter what you put in your database.yml, which to me is nice, as I can include it in git without worrying about production db passwords.

You may choose another database by setting the ENV['DATABASE_URL'] (use heroku config:add DATABASE_URL=....)

Check heroku documentation https://devcenter.heroku.com/articles/ruby-support#build-behavior

Upvotes: 15

Related Questions