Reputation: 5451
I've added heroku postgres addon.
The DATABASE_URL is something like postgres://xxxxxxxxx:[email protected]:5432/ddo2ahvosfggq
I want the database name to be like my_app_database. I want to rename ddo2ahvosfggq to my_app_database.
How can I do that?
Can I use ALTER DATABASE? http://www.postgresql.org/docs/9.1/static/sql-alterdatabase.html
There is already a question in StackOverflow How to rename database in Heroku?
But the answers is to rename the app. I don't know how renaming app will work?
If my_app is the name of my heroku app. Will the below DATABASE_URL work?
postgres://xxxxxxxxx:[email protected]:5432/my_app
Upvotes: 1
Views: 1599
Reputation: 9485
You can't. It's a Database-as-a-Service (DBaaS) and database name is not customizable there. You just get it from the service and use. Since it's not a user-facing detail for web applications, pretty names are of no use. So why bother?
Most actions you can do with your database are listed on Heroku Postgres website. You can:
Upvotes: 4
Reputation: 101851
You don't ever really need to type in the name of the production database on Heroku.
Heroku has a post commit hook which writes the production DB details into /config/database.yml
.
If you ever really need to to query the database without a model you would establish a connection by:
ActiveRecord::Base.establish_connection
query = ActiveRecord::Base.connection.execute('SELECT * FROM foo;')
Upvotes: 2