Reputation: 3425
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.
Upvotes: 40
Views: 26844
Reputation: 3885
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.
Upvotes: 0
Reputation: 702
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
Upvotes: 2
Reputation: 2002
hope everyone confuses with placeholder and constant.
Assume having a db with name d6u5qhrlnbdfmp. then it is NOT necessary to type
heroku pg:reset d6u5qhrlnbdfmp
Instead we can plainly type
heroku pg:reset DATABASE_URL
the sample output
E:\git\stutzen>heroku pg:reset d6u5qhrlnbdfmp --app stutzen
! Unknown database: d6u5qhrlnbdfmp. Valid options are: DATABASE_URL, HEROKU_
POSTGRESQL_CYAN_URL
E:\git\stutzen>heroku pg:reset DATABASE_URL --app stutzen
! WARNING: Destructive Action
! This command will affect the app: stutzen
! To proceed, type "stutzen" or re-run this command with --confirm stutzen
> stutzen
Resetting HEROKU_POSTGRESQL_CYAN_URL (DATABASE_URL)... done
Upvotes: 59
Reputation: 608
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.
Upvotes: 13
Reputation: 933
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
Upvotes: 8
Reputation: 13543
URL consists of the following parts:
scheme://username:password@host:port/database
So, in your case DB name is d14grmkt
.
Upvotes: 23