mirror of
https://github.com/3ybactuk/marketplace-go-service-project.git
synced 2025-10-30 14:03:45 +03:00
[hw-8] add: repo layer
This commit is contained in:
@@ -1,12 +1,41 @@
|
||||
BINDIR=${CURDIR}/bin
|
||||
BINDIR=${CURDIR}/../bin
|
||||
PACKAGE=route256/comments
|
||||
|
||||
MIGRATIONS_FOLDER := ./db/migrations/
|
||||
LOCAL_DB_NAME := route256
|
||||
LOCAL_DB_DSN := postgresql://user:password@localhost:5433/route256?sslmode=disable
|
||||
|
||||
PROD_USER := loms-user
|
||||
PROD_PASS := loms-password
|
||||
PROD_DB := postgres-master
|
||||
|
||||
PROD_MIGRATIONS := ./comments/db/migrations/
|
||||
|
||||
build: bindir
|
||||
echo "build comments"
|
||||
go build -o ${BINDIR}/comments cmd/server/main.go
|
||||
|
||||
bindir:
|
||||
mkdir -p ${BINDIR}
|
||||
|
||||
build: bindir
|
||||
echo "build comments"
|
||||
|
||||
|
||||
# Used for CI
|
||||
run-migrations:
|
||||
echo "run migrations"
|
||||
$(GOOSE) -dir $(PROD_MIGRATIONS) postgres "postgresql://$(PROD_USER):$(PROD_PASS)@$(PROD_DB):5432/comments_db?sslmode=disable" up
|
||||
|
||||
db-create-migration:
|
||||
$(BINDIR)/goose -dir $(MIGRATIONS_FOLDER) create -s $(n) sql
|
||||
|
||||
db-migrate:
|
||||
$(BINDIR)/goose -dir $(MIGRATIONS_FOLDER) postgres "$(LOCAL_DB_DSN)" up
|
||||
|
||||
db-migrate-down:
|
||||
$(BINDIR)/goose -dir $(MIGRATIONS_FOLDER) postgres "$(LOCAL_DB_DSN)" down
|
||||
|
||||
db-reset-local:
|
||||
psql -c "drop database if exists \"$(LOCAL_DB_NAME)\""
|
||||
psql -c "create database \"$(LOCAL_DB_NAME)\""
|
||||
make db-migrate
|
||||
|
||||
.PHONY: generate-sqlc
|
||||
generate-sqlc:
|
||||
$(BINDIR)/sqlc generate
|
||||
|
||||
Reference in New Issue
Block a user