I was in a situation where I had to use SQL on a shared staging database. I was scared.
The purpose of this repository is to become more familiar with PostgreSQL and dbmate in both writing migraitions and writing SQL queries.
Personally, I have used a lot of ORMs and SQL builders in the past on personal projects. I'm not so confident with pure SQL on top of working with a live database that others would potentially use.
- docker-compose
- docker
- make
Optional:
In order to initialise the database via docker/docker-compose:
docker-compose up --build
This will create a docker container with a postgresql image exposed on port 5999.
Once the database up, you can initialise write a migration, using dbmate
.
dbmate new <name of migration>
Refer to dbmate documentation.
The makefile contains some commands for ease.
make up # will migrate to latest
make down # will do back one migration
Connecting to the database via psql
.
make connect
Feedback is welcomed.