Using an existing Heroku database

Let’s say you have an existing Heroku Postgres database with data in it, and you’d like add GraphQL on it.

Note

In case you’re exposing an existing database (esp. if it is production), please configure an admin secret key for the console and the GraphQL endpoint.

Step 1: Deploy Hasura on Heroku

Deploy Hasura on Heroku by clicking on this button:

heroku_deploy_button

Follow the Heroku instructions to deploy, check if the Hasura console loads up when you View app and then head to the Manage App screen on your Heroku dashboard.

This will deploy Hasura with a free Postgres add-on automatically provisioned.

Step 2: Remove the created Postgres add-on in the app

Head to your Heroku dashboard and delete the Postgres add-on created in the previous step:

../../../../_images/remove-heroku-postgres-addon.png

Step 3: Configure environment variables

Now configure the DATABASE_URL with your existing Heroku Postgres database URL and a HASURA_GRAPHQL_ADMIN_SECRET if you want to secure your endpoint.

../../../../_images/heroku-database-url-access.png

Note

Hasura GraphQL engine needs access permissions to your Postgres database as described in Postgres permissions

Step 4: Track tables and relationships

Wait for the GraphQL engine to restart and then see Setting up GraphQL schema using an existing database to enable GraphQL over the database.