3

Currently I have my Ruby on Rails program running great on my Linux Ubuntu development environment, and now I want to run it live on my website, and get it hosted on Heroku.

The problem is that I don't know how to create a user and a database on Heroku. I have tried the command

heroku run rake db:create

I got the error:

permission denied for database - user does nothave connect privilage

I also tried the command

heroku run su - postgres

and it posted that I need to use the terminal so I do not know how to proceed.

This is my database.yml

default: &default
  adapter:  postgresql
  host:     localhost

development:
  <<: *default
  database: app_development

test:
   <<: *default
   database: app_test

production:
  <<: *default
  database: app_production

How do I set up my database and the proper connections with my Heroku PostgreSQL database?

i also did this

heroku pg:info 

which gave me this

shrouded-reaches-3063 has no heroku-postgresql databases.

also tried this

heroku addons | grep POSTGRES

but nothing was printed

heroku addons:create heroku-postgresql:hobby-dev 
!    `addons:create` is not a heroku command.
!    See `heroku help` for a list of available commands.

also this

heroku pg:wait

and displayed nothing... this really is something T_T really need some major help here , and will be really greatful for any help

2 Answers 2

6

Have you provisioned a database? What does heroku addons say? You can create an add-on as documented here with heroku addons:create heroku-postgresql:hobby-dev

Sign up to request clarification or add additional context in comments.

7 Comments

I strongly suggest removing your password from your comment. Further, the full command you want is heroku addons:create heroku-postgresql:hobby-dev - see the article here for full info: devcenter.heroku.com/articles/…
heroku addons:create heroku-postgresql:hobby-dev ! addons:create is not a heroku command. ! See heroku help for a list of available commands.
that is what it returns i have been trying to get this to work all afternoon but to no avail T_T
in the start i specified that it will use the PG, and its working great locally, but with heroku its now working , it wont even let me create the database T_T
Looks like the docs are outdated: try heroku addons:add heroku-postgresql:hobby-dev - note the use of add vs. create. You can also add a DB via the web dashboard, and use tab completion to see available commands when using the Heroku Toolbelt.
|
1

!!!NOT IN THE DOCUMENTATION!!!

 heroku addons:create heroku-postgresql:hobby-dev --version=12 --app "APPNAME" --name "APPNAME-database"

--app : Specify the heroku app you want to add the database too. Really good if you have more than one heroku app.

--name : The name you would like to give your database. I like to take my application name and postfix it with "database" as a nice convention. Better than whatever randomly generated name you'll get.

APPNAME: A placeholder for whatever your application name is.

No mention of any of this on heroku.com documentation pages for addons in general or postgres addon. I think I came to this via guessing based on documentation for creating apps. But I don't remember. This was in my notes from 5+ years ago. However, I just tried it, still works as of 2022.05.14.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.