33 lines
1.1 KiB
Makefile
33 lines
1.1 KiB
Makefile
GOOS=$(shell go env GOOS)
|
|
GOARCH=$(shell go env GOARCH)
|
|
GOBIN=$(shell go env GOBIN)
|
|
ifeq ($(GOBIN),)
|
|
GOBIN := $(shell go env GOPATH)/bin
|
|
endif
|
|
OSARCH=$(shell uname -m)
|
|
SQLC_PATH=$(GOBIN)/sqlc
|
|
GOOSE_PATH=$(GOBIN)/goose
|
|
|
|
.PHONY: install-goose
|
|
install-goose:
|
|
@echo "Installing github.com/pressly/goose..."
|
|
@(test -f $(GOOSE_PATH) && echo "github.com/pressly/goose is already installed. Skipping...") || (wget -q -O $(GOOSE_PATH) https://github.com/pressly/goose/releases/download/v3.15.0/goose_$(GOOS)_$(OSARCH) && chmod u+x $(GOOSE_PATH))
|
|
|
|
.PHONY: install-sqlc
|
|
install-sqlc:
|
|
@echo "Installing github.com/sqlc-dev/sqlc..."
|
|
@(test -f $(SQLC_PATH) && echo "github.com/sqlc-dev/sqlc is already installed. Skipping...") || (wget -qO- https://github.com/sqlc-dev/sqlc/releases/download/v1.20.0/sqlc_1.20.0_$(GOOS)_$(GOARCH).tar.gz | tar -xz -C $(GOBIN)/)
|
|
|
|
.PHONY: generate
|
|
generate: install-sqlc
|
|
@echo "Running go generate..."
|
|
go generate ./...
|
|
|
|
.PHONY: create-sql-migration
|
|
create-sql-migration: install-goose
|
|
@goose -dir migrations create $(name) sql
|
|
|
|
.PHONY: validate-migrations
|
|
validate-migrations: install-goose
|
|
@goose -dir migrations -v validate
|