keepforever / a-prisma2

some boilerplate to use as a jump off point for creating a GraphQL backend.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

  1. Start Postgres Docker Conatiner

10-27-2019, new spin up postgres command

docker run -p 5432:5432 -d \
    -e POSTGRES_PASSWORD=postgres \
    -e POSTGRES_USER=postgres \
    -e POSTGRES_DB=mydatabase \
    -v pgdata:/var/lib/postgresql/data \
    postgres

Old spin up postgres command

docker run -p 5432:5432 -d \
    -e POSTGRES_PASSWORD=postgres \
    -e POSTGRES_USER=postgres \
    -e POSTGRES_DB=prisma_two_db \
    -v pgdata:/var/lib/postgresql/data \
    postgres

The POSTGRES_PASSWORD, POSTGRES_USER, POSTGRES_DB used to instantiate the PostgreSQL docker container get used in prsima/schema.prisma like so:

datasource db {
    provider = "postgresql"
    url      = "postgresql://postgres:postgres@localhost:5432/prisma_two_db?schema=prisma_two_db_schema"
}
  1. Once your PostgreSQL backend is up and running, you need to create the tables. This is facilitated by the prisma2 cli
  • instantiate your migration:
prisma2 lift save --name '<whatever_name>'
  • run migration
prisma2 lift save --name 'add-profile-model'

Afterwards (and assuming a success message), if you were to connect to your database (for example with the popular tableplus.io), you should see the migration changes reflected in empty tables.

Fresh Start Protocol

When you want to erase the data and data volume associated with the container you originally created run:

# remove container
docker rm <container_name>
docker volume rm pgdata

then, begin again at step 1 at the top.

common cli commands

prisma2 lift save --name '<whatever_name>'
prisma2 lift save --name 'add-profile-model'
prisma2 lift up
Expand to the view the collapsed text.

This is collapsed.

This is NOT collapsed.

About

some boilerplate to use as a jump off point for creating a GraphQL backend.


Languages

Language:TypeScript 100.0%