Book Image

Heroku Cookbook

By : Mike Coutermarsh
Book Image

Heroku Cookbook

By: Mike Coutermarsh

Overview of this book

Heroku is a Platform as a Service that enables developers to rapidly deploy and scale their web applications. Heroku is designed for developer happiness, freeing developers from doing system administrative tasks such as configuring servers and setting up load balancers. Developers are able to focus on what they do best, building web applications, while leaving the details of deployment and scaling to the experts at Heroku. This practical guide is packed with step-by-step solutions to problems faced by every production-level web application hosted on Heroku. You'll quickly get comfortable with managing your Heroku applications from the command line and then learn everything you need to know to deploy and administer production-level web applications.
Table of Contents (17 chapters)
Heroku Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Promoting a Heroku database


In your applications, you should be using the DATABASE_URL configuration variable to connect to your database. It's not an uncommon occurrence, especially when upgrading a database to have multiple databases for a single application. Heroku makes it easy for us to manage which database's credentials are assigned to DATABASE_URL through a process known as promotion. At any time, you can promote any database assigned to your application and make it primary by updating DATABASE_URL. This makes it simple to swap databases without any risk of pasting incorrect credentials.

How to do it…

To start, let's open up a terminal and take a look at our current configuration variables:

  1. Let's run heroku config to view our existing settings:

    $ heroku config
    DATABASE_URL: postgres://user:[email protected]:5432/d8hg98vjvtisu4
    HEROKU_POSTGRESQL_GRAY_URL: postgres://user:[email protected]:5792/d75vuqlr37fe
    HEROKU_POSTGRESQL_ORANGE_URL...