- Postgres
- NodeJS
Make sure you have set up Postgres in your dev machine.
During setup we will create the following:
- A
app_user
Postgres role, with password1234
. - A
shelterdb
database owned byapp_user
. - A connection URL that assumes the above, and also that your Postgres server is running on
localhost
on port5432
.
If you wish to use different names, password or port number, you will need to adapt the following instructions, as well as the psql
script inside your package.json
file.
-
We will create a Postgres
app_user
role with password1234
, and ashelterdb
Postgres database.Connect to the
postgres
database:psql postgres
Paste and run the following SQL commands:
DROP DATABASE IF EXISTS shelterdb; DROP ROLE IF EXISTS app_user; CREATE ROLE app_user WITH LOGIN PASSWORD '1234'; ALTER ROLE app_user CREATEDB; CREATE DATABASE shelterdb OWNER app_user;
Quit the connection to the
postgres
database:\q
-
Create a
.env
file at the root of the project:DATABASE_URL="postgresql://app_user:1234@localhost:5432/shelterdb?schema=public"
-
Launch the project:
npm install npm run db:init npm run dev
-
Provision a Postgres database, deploy the web service to Render by linking your GitHub repo, set
DATABASE_URL
env variable. -
The build command in Render should be
npm run build