- Postgres
- NodeJS
Make sure you have set up Postgres in your dev machine.
During setup we will create the following:
- A
app_userPostgres role, with password1234. - A
shelterdbdatabase owned byapp_user. - A connection URL that assumes the above, and also that your Postgres server is running on
localhoston 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_userrole with password1234, and ashelterdbPostgres database.Connect to the
postgresdatabase: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
postgresdatabase:\q
-
Create a
.envfile 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_URLenv 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
devscript so it injects the.envfile - 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/featuremodel 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())
}