- 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 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
- Test the current state of the application (should work)
- Run through the steps above to set up the local database
- Fix the
dev
script so it injects the.env
file - Use helmet middleware
- Disconnect the old model and connect the Prisma one
- Flesh out the schema for Pet
- Create migration files, explain scripts
- Alter schema to add
favToy
, run migrations - Inspect the db using PgAdmin 4
- Demo pull request
- Walk over deployment
Make sure to have cloned this repo WITHOUT forking.
https://github.com/codepath/prisma-express-setup
git fetch
git reset --hard origin/feature
model Pet {
id Int @id @default(autoincrement())
name String
type String
age Int?
adopted Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @default(now())
}