Skip to content

shivan-s/db-playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DB playground

Purpose

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.

Requirements

  • docker-compose
  • docker
  • make

Optional:

How to use

1. Initialise database

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.

2. Make a migration

Once the database up, you can initialise write a migration, using dbmate.

dbmate new <name of migration>

Refer to dbmate documentation.

3. Run a migration

The makefile contains some commands for ease.

make up # will migrate to latest


make down # will do back one migration

4. Connect to database

Connecting to the database via psql.

make connect

Feedback

Feedback is welcomed.

About

Playground for PostgreSQL

Resources

License

Stars

Watchers

Forks