Database Reference
In-Depth Information
Creating the first database
Now you have the Heroku Postgres add-on installed in your application and the first data-
base was automatically created by the HEROKU_POSTGRESQL_GOLD_URL environ-
ment variable on Heroku and is available; this variable points the connection string to the
database.
Tip
The name of the HEROKU_POSTGRESQL_GOLD_URL variable follows the pattern
HEROKU_POSTGRESQL_[COLOR]_URL , so don't worry if a different name appears.
Heroku allows you to add the Heroku Postgres add-on more than once in the same applic-
ation; it allows you to have many PostgreSQL databases in the same application. In this
case, you will have many configuration variables to connect to the database, one for each
database.
Tip
There is an environment variable called DATABASE_URL ; this variable always points to
the primary database.
If you want to view all the available environment variables, you must use the following
command:
$ heroku config --app your-app-name
=== your-app-name Config Vars
DATABASE_URL:
postgres://username:password@host:5432/database
HEROKU_POSTGRESQL_GOLD_URL:
postgres://username:password@host:5432/database
In this case, you have the DATABASE_URL and HEROKU_POSTGRESQL_GOLD_URL
variables that point to the same database connection.
If you visit the Heroku dashboard, you will see the Heroku Postgres add-on added in the
Hobby Dev plan.
Search WWH ::




Custom Search