.PHONY: generate test test-short test-integration lint build

SQLC_VERSION := 1.31.1

generate:
	docker run --rm -v "$(CURDIR):/src" -w /src sqlc/sqlc:$(SQLC_VERSION) generate

test:
	go test -race ./...

test-short:
	go test -short -race ./...

# Full suite incl. integration tests, against the dedicated minstrel_test
# DB so a run never truncates the dev `minstrel` DB (Fable #339). Ensures
# the test DB exists (idempotent — createdb errors if present, ignored).
test-integration:
	docker compose up -d postgres
	-docker compose exec -T postgres createdb -U minstrel minstrel_test
	# -p 1: integration packages share one test DB and each TRUNCATEs it;
	# concurrent package binaries deadlock on TRUNCATE. Serialize packages.
	MINSTREL_TEST_DATABASE_URL=postgres://minstrel:minstrel@localhost:5432/minstrel_test?sslmode=disable go test -p 1 -race ./...

lint:
	golangci-lint run ./...

build:
	go build -o bin/minstrel ./cmd/minstrel
