-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile
27 lines (19 loc) · 856 Bytes
/
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
.PHONY: network postgres createdb dropdb migrateup migratedown addmigration test
network:
docker network create gn-network
postgres:
docker run --name postgres12 --network gn-network -p 5432:5432 -e POSTGRES_USER=root -e POSTGRES_PASSWORD=secret -d postgres:12-alpine
createdb:
docker exec -it postgres12 createdb --username=root --owner=root bn_db
docker exec -it postgres12 sh -c "psql -U root -d bn_db -c \"CREATE SCHEMA IF NOT EXISTS batnoter;\" "
dropdb:
docker exec -it postgres12 dropdb bn_db
# `up` migration is supported by application with cobra command
migrateup:
go run main.go migrateup
migratedown:
migrate -path migrations -database "postgresql://root:secret@localhost:5432/bn_db?search_path=batnoter&sslmode=disable" -verbose down
addmigration:
migrate create -ext sql -dir migrations ${file}
test:
go test -v -cover ./...