Author: Kyungrae Kim
Below steps allows local development environment to work with Heroku Postgres.
After creating an app on Heroku to host a Heroku Postgres:
-
Reset the deployed Heroku Postgres using the following command:
heroku pg:reset -a APP_NAME
-
Confirm the reset by entering the APP_NAME
APP_NAME
-
Run a SQL script to deploy a database to the APP_NAME
heroku pg:psql -a APP_NAME < SQL_SCRIPT_NAME
-
Update
const client = new pg.Client();
with the below codeblock to connect to Heroku Postgres from the local development environmentconst client = new pg.Client({ connectionString: process.env.DATABASE_URL, ssl: { rejectUnauthorized: false } });
-
Update the
.env
with the APP_NAME's Heroku Postgres DATABASE_URLDATABASE_URL=HEROKU_DATABASE_URL
- What to do when student's Nodejs version is above 12 on macOS?