Copy env and populate with data:
cp .env.template .envFor database DSN use somethong like this:
DB_DSN=postgres://username:password@localhost/databse?sslmode=disableInstall additional packages:
go install github.com/cosmtrek/air@latest # for live reload
brew install golang-migrate
brew install pre-commit # style check
pre-commit installRun containers:
docker compose up -d
docker compose ps # everything has to be up and runningConnect to database using docker compose exec db psql -U postgres. Following commands might raise an exception that something is already exists – it's ok:
CREATE DATABASE greenlight;
CREATE ROLE greenlight WITH LOGIN PASSWORD 'password';
CREATE EXTENSION IF NOT EXISTS citext;Apply migrations. Value of database option is DB_DSN from environment:
migrate -path=./migrations -database="postgres://greenlight:password@localhost/greenlight?sslmode=disable" up[ ] add init sql (role creation etc) to docker compose
[ ] move golang with air to docker
[ ] apply migration inside docker