Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rename database in Heroku?

I've created a new database in Heroku, showing in my dashboard; when I go to settings, it does not allow me to rename, stating 'Internal Server Error'. What can I do to rename my database?

like image 398
user2698988 Avatar asked Aug 26 '13 23:08

user2698988


2 Answers

It may be clearer to think of it this way:

  1. You can rename an app heroku apps:rename --app OLDNAME NEWNAME

  2. You can rename an addon (in your case, postgres instance): heroku addons:rename OLDNAME NEWNAME To find the current name, do heroku addons.

  3. But you also have to understand heroku aliases. These are how heroku automatically sets config vars for you (its the config vars which the aliases set that you see in your settings page). Here are the docs. In a nutshell, you can't actually rename an alias directly, but you can add a second alias pointing to the same place, then remove the old one. See here.

like image 39
mwal Avatar answered Sep 18 '22 06:09

mwal


It looks like the method for renaming a Heroku DB has changed since this was last updated; the answer given in this reply is no longer valid.

I've spoken with Heroku support, and the current way to rename a Heroku DB is using the heroku addons:rename command (you can look up some brief CLI help on it with the command heroku help addons:rename.)

For example: if your DB is named postgresql-loudly-9983 and is attached to the app bumping-softly-6892, and you'd like to rename it to stats-db, your command would be the following:

heroku addons:rename postgresql-loudly-9983 stats-db -a bumping-softly-6892

like image 56
Sydin Avatar answered Sep 22 '22 06:09

Sydin