init socle
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
4ba5c58a37
commit
599479d746
12 changed files with 400 additions and 0 deletions
44
Makefile
Normal file
44
Makefile
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
-include .env
|
||||
export
|
||||
|
||||
BINARY = bin/api
|
||||
DB_URL ?= postgres://account:account@localhost:5432/account?sslmode=disable
|
||||
GOBIN = $(shell go env GOPATH)/bin
|
||||
MIGRATE = $(GOBIN)/migrate
|
||||
SQLC = $(GOBIN)/sqlc
|
||||
|
||||
.PHONY: build run test docker-up docker-down migrate-up migrate-down migrate-create sqlc-gen
|
||||
|
||||
build:
|
||||
go build -o $(BINARY) ./cmd/api
|
||||
|
||||
run:
|
||||
go run ./cmd/api
|
||||
|
||||
test:
|
||||
go test ./...
|
||||
|
||||
## Docker
|
||||
docker-up:
|
||||
docker compose up -d
|
||||
|
||||
docker-down:
|
||||
docker compose down
|
||||
|
||||
docker-reset:
|
||||
docker compose down -v
|
||||
|
||||
## Migrations (nécessite: go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest)
|
||||
migrate-up:
|
||||
$(MIGRATE) -path migrations -database "$(DB_URL)" up
|
||||
|
||||
migrate-down:
|
||||
$(MIGRATE) -path migrations -database "$(DB_URL)" down 1
|
||||
|
||||
migrate-create:
|
||||
@test -n "$(name)" || (echo "usage: make migrate-create name=xxx" && exit 1)
|
||||
$(MIGRATE) create -ext sql -dir migrations -seq $(name)
|
||||
|
||||
## sqlc (nécessite: go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest)
|
||||
sqlc-gen:
|
||||
$(SQLC) generate
|
||||
Loading…
Add table
Add a link
Reference in a new issue