mirror of
https://github.com/3ybactuk/marketplace-go-service-project.git
synced 2025-10-30 14:03:45 +03:00
[hw-4] add postgres db
This commit is contained in:
@@ -1,11 +1,40 @@
|
||||
BINDIR=${CURDIR}/bin
|
||||
BINDIR=${CURDIR}/../bin
|
||||
PACKAGE=route256/loms
|
||||
MIGRATIONS_FOLDER := ./db/migrations/
|
||||
LOCAL_DB_NAME := route256
|
||||
LOCAL_DB_DSN := postgresql://user:password@192.168.64.4:5433/route256?sslmode=disable
|
||||
|
||||
PROD_USER := loms-user
|
||||
PROD_PASS := loms-password
|
||||
PROD_DB := postgres-master
|
||||
|
||||
PROD_MIGRATIONS := ./loms/db/migrations/
|
||||
|
||||
bindir:
|
||||
mkdir -p ${BINDIR}
|
||||
|
||||
build: bindir
|
||||
echo "build loms"
|
||||
go build -o ${BINDIR}/loms cmd/server/main.go
|
||||
|
||||
# Used for CI
|
||||
run-migrations:
|
||||
echo "run migrations"
|
||||
$(GOOSE) -dir $(PROD_MIGRATIONS) postgres "postgresql://$(PROD_USER):$(PROD_PASS)@$(PROD_DB):5432/loms_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