This post describes a quick setup which allows one to develop a postgres sql backed application locally. (This is taken from this eggheadio video.)
Create a docker-compose.yml
file as follows.
version: "3.8"
services:
db:
image: "postgres:12"
ports:
- "54320:5432"
volumes:
- ./pgdata:/var/lib/postgresql/data
environment:
- POSTGRES_USER=alice
- POSTGRES_PASSWORD=wonderland
- POSTGRES_DB=myawesomedb
Create a local folder which will persist data and start the service.
mkdir pgdata
docker-compose up -d
Once it is up and running, verify you can log into postgres shell.
docker-compose run db bash
Inside the docker container run the following and enter password wonderland
defined above.
psql --host=db --username=alice --dbname=myawesomedb
You should see psql shell. You can exit by pressing Ctrl+D twice.
At this point most likely you already have prisma
setup locally by some variation of the following commands.
npx prisma init
npx prisma generate
Now you can run the following command to create and apply migrations.
npx prisma migrate dev --name init
Top comments (0)