Recently heroku upgraded and migrated their postgres database to a different stack – unfortunately that broke wordpress blogs hosted on heroku. I wrote a detailed article on how to host your wordpress blog on heroku some time back – I found a few very useful wordpress bootstraps for heroku. After the recent upgrade, all the wp-config settings were invalidated and your wordpress blog could not connect to the database. There are two things to notice :
- Your database is safe – its just moved and renamed
- You need to edit your wp-config to change the db settings to the migrated database
But, where on earth is my wp-config.php ? If you are like me, you dont have the original copy which you used to create your blog in the first place. Many of you might not have hosted that wordpress installation on github. So how to update the wp-config ?
Trick is to know that heroku internally has a github link to every app it hosts. You will need to find which github repo heroku is internally linking your application to and you will need to find the modified database name, username, password and host.
- Finding github repo for your app is easy. Login to heroku and click on the app that is used to host your blog.
- Check the ‘Settings’ tab and you will find something like – Git URL:
- <yourapp> is the actual name your app
- Now head back to your terminal and clone this particular repo as follows
git clone firstname.lastname@example.org:furious-robot-218.git -o heroku
Initialized empty Git repository in /Users/adam/facebook-template-php/.git/
remote: Counting objects: 273, done.
remote: Compressing objects: 100% (183/183), done.
remote: Total 273 (delta 2), reused 261 (delta 0)
Receiving objects: 100% (273/273), 25.55 KiB, done.
Resolving deltas: 100% (2/2), done.
- Once your code is cloned locally, head over to ‘Resources’ tab and you will find a link to ‘Heroku Postgres Dev :: Cobalt’
- Clicking on this link will show you a page where you will find the migrated DB name, username, password and host – Note these down
- Head back to your local terminal and edit wp-config.php file and modify the following with the new values :
/** The name of the database for WordPress */
/** MySQL database username */
/** MySQL database password */
/** MySQL hostname */
- Once you have updated wp-config.php with the modified values. Push it to heroku as follows:
$ git commit -am "changed greeting"
[master 0ff313a] changed greeting
1 files changed, 1 insertions(+), 1 deletions(-)
$ git push heroku
Thats it. Your modified settings are uploaded to heroku and your app is restarted.