Skip to content

Instantly share code, notes, and snippets.

@jeremymaya
Last active November 25, 2020 18:47
Show Gist options
  • Save jeremymaya/9da0b66eac3d35ff8803973492eff9e9 to your computer and use it in GitHub Desktop.
Save jeremymaya/9da0b66eac3d35ff8803973492eff9e9 to your computer and use it in GitHub Desktop.

Heroku Postgres Deployment Instruction

Author: Kyungrae Kim


How to deploy Student's Database using Heroku Postgres

Below steps allows local development environment to work with Heroku Postgres.

After creating an app on Heroku to host a Heroku Postgres:

  1. Reset the deployed Heroku Postgres using the following command:

    heroku pg:reset -a APP_NAME
  2. Confirm the reset by entering the APP_NAME

    APP_NAME
  3. Run a SQL script to deploy a database to the APP_NAME

    heroku pg:psql -a APP_NAME < SQL_SCRIPT_NAME
  4. Update const client = new pg.Client(); with the below codeblock to connect to Heroku Postgres from the local development environment

    const client = new pg.Client({
      connectionString: process.env.DATABASE_URL,
      ssl: {
        rejectUnauthorized: false
      }
    });
  5. Update the .env with the APP_NAME's Heroku Postgres DATABASE_URL

    DATABASE_URL=HEROKU_DATABASE_URL
    

Other Possible Issues


References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment