-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
35 lines (24 loc) · 1.33 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
include .env
validate_env:
@if [ -z "${DB_USER}" ]; then echo "Error: DB_USER is not defined in .env"; exit 1; fi
@if [ -z "${POSTGRES_PASSWORD}" ]; then echo "Error: POSTGRES_PASSWORD is not defined in .env"; exit 1; fi
run_db_container: validate_env
docker run --name postgres12 -p 5433:5432 -e POSTGRES_USER=${DB_USER} -e POSTGRES_PASSWORD=${POSTGRES_PASSWORD} -d postgres:12-alpine
start_db:
docker start postgres12
stop_db:
docker stop postgres12
create_db: validate_env
docker exec -it postgres12 createdb --username=${DB_USER} --owner=${DB_USER} fit_forge
drop_db:
docker exec -it postgres12 dropdb fit_forge
migrate_up_all: validate_env
migrate -path migrations -database "postgresql://${DB_USER}:${POSTGRES_PASSWORD}@localhost:5433/fit_forge?sslmode=disable" -verbose up
migrate_down_all: validate_env
migrate -path migrations -database "postgresql://${DB_USER}:${POSTGRES_PASSWORD}@localhost:5433/fit_forge?sslmode=disable" -verbose down
migrate_down_1: validate_env
migrate -path migrations -database "postgresql://${DB_USER}:${POSTGRES_PASSWORD}@localhost:5433/fit_forge?sslmode=disable" -verbose down 1
unit_test_coverage:
@go test -coverprofile=coverage.out ./...
@go tool cover -html=coverage.out
.PHONY: run_db_container start_db stop_db create_db drop_db migrate_up_all migrate_down_all migrate_down_1 unit_test_coverage