How To Create Golang REST API: Project Layout Configuration [Part 2]

$ go get -u
$ migrate create -ext sql -dir ./db/migrations create_user
go get -u
# remove all containers docker container
rm -f $(docker container ps -a -q)
# clear volumes
docker volume prune -f
# start app
docker-compose up --build
# connect to pg
docker container docker exec -it $(docker ps --filter name=pg --format "{{.Names}}") /bin/bash
# launch psql cli
psql -U postgres -W
# ensure both DBs still present
# connect to boilerplate database and list tables
\c boilerplate
# do same for boilerplatetest
\c boilerplatetest
# in both databases you should see users table
# migrate boilerplatetest db down
go run cmd/dbmigrate/main.go \
-migrate=down \
-dbname=boilerplatetest \

# you can now repeat steps from above to connect to pg container
# and ensure that users table is missing from boilerplatetest DB.

# now bring it back up
go run cmd/dbmigrate/main.go \
-migrate=up \
-dbname=boilerplatetest \



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Dan Stenger

Dan Stenger

Software engineer focusing on simplicity and reliability. GO and functional programming enthusiast