[hw-8] add: repo layer

This commit is contained in:
3ybactuk
2025-07-25 23:04:31 +03:00
committed by 3ybacTuK
parent c1e8934646
commit 6420eaf3d7
25 changed files with 4194 additions and 6 deletions

View File

@@ -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