- Start Postgres Docker Conatiner
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
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"
}
- 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.
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