-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
50 lines (37 loc) · 1.21 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
DB_CONTAINER=pokemondb
DB_PASSWORD=1234
DB_USER=postgres
DB_NAME = postgres
GOOSE_DRIVER=postgres
GOOSE_DBSTRING="postgres://${DB_USER}:${DB_PASSWORD}@localhost:5432/${DB_NAME}?sslmode=disable"
GOOSE_MIGRATION_DIR=./schema
init:
docker run --name testdb -e POSTGRES_PASSWORD=1234 -e POSTGRES_HOST_AUTH_METHOD=trust -p 5432:5432 -d postgres
goose -dir ${GOOSE_MIGRATION_DIR} ${GOOSE_DRIVER} ${GOOSE_DBSTRING} ${GOOSE_MIGRATION_DIR } up
test:
docker start testdb
go run ./cmd/.
build:
docker-compose build
initUp:
docker-compose build
@echo "starting docker container"
docker-compose up -d
@echo "initializing database schema"
goose -dir ${GOOSE_MIGRATION_DIR} ${GOOSE_DRIVER} ${GOOSE_DBSTRING} ${GOOSE_MIGRATION_DIR } up
@echo "initialization finished"
docker-compose down
up:
docker-compose up -d
down:
docker-compose down
startPsql:
docker exec -ti ${DB_CONTAINER} psql -U ${DB_USER}
migrateup:
@echo "migrating up"
goose -dir ${GOOSE_MIGRATION_DIR} ${GOOSE_DRIVER} ${GOOSE_DBSTRING} ${GOOSE_MIGRATION_DIR } up
@echo "migrating finished"
migratedown:
@echo "migrating down"
goose -dir ${GOOSE_MIGRATION_DIR} ${GOOSE_DRIVER} ${GOOSE_DBSTRING} ${GOOSE_MIGRATION_DIR } down
@echo "migrating finished"