'Heroku postgresql database name

This is the command I have to find the name of a heroku database:

$ heroku config | grep POSTGRESQL

I get a result similar to:

HEROKU_POSTGRESQL_NAVY_URL: postgres://wxjwilh:[email protected]:52/d14grmkt

which part of this output is the database name I can use with the command:

$ heroku pg:reset <DATABASE>

I tried using the whole url but got an invalid argument error.



Solution 1:[1]

URL consists of the following parts:

scheme://username:password@host:port/database

So, in your case DB name is d14grmkt.

Solution 2:[2]

I had a hard time to reset my database on Heroku. I post this, because I think it's the most straightforward solution. To find out the database name cd to your application folder and type:

heroku pg:info

Output will be something like

=== HEROKU_POSTGRESQL_BRONZE_URL
#other stuff

To reset the database type:

heroku pg:reset HEROKU_POSTGRESQL_BRONZE_URL

you have to confirm with your application name.

Solution 3:[3]

While using the command:

$ heroku pg:reset DATABASE

It will tell you the available database name like this:

! Unknown database: DATABASE_URL. Valid options are: HEROKU_POSTGRESQL_COPPER_URL, SHARED_DATABASE

so try the options it gave like this

$ heroku pg:reset HEROKU_POSTGRESQL_COPPER_URL

Solution 4:[4]

Late to the party, but if you need the db name, for example to add it as an addon to another instance, you run

heroku addons

In the list you will see your postgres addon, in the 'Add-on' column is the name of the db app that is attached

Solution 5:[5]

NOT MENTIONED IN THE HEROKU WEBSITE 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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Audrius Kažukauskas
Solution 2 ksu
Solution 3 Ray Shih
Solution 4 marc_s
Solution 5 KANJICODER