forked from JacobSNGoodwin/memrizr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
34 lines (26 loc) · 1.17 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
.PHONY: keypair migrate-create migrate-up migrate-down migrate-force
PWD = $(shell pwd)
ACCTPATH = $(PWD)/account
MPATH = $(ACCTPATH)/migrations
PORT = 5432
N = 1
create-keypair:
@echo "Creating an rsa 256 key pair"
openssl genpkey -algorithm RSA -out $(ACCTPATH)/rsa_private_$(ENV).pem -pkeyopt rsa_keygen_bits:2048
openssl rsa -in $(ACCTPATH)/rsa_private_$(ENV).pem -pubout -out $(ACCTPATH)/rsa_public_$(ENV).pem
migrate-create:
@echo "---Creating migration files---"
migrate create -ext sql -dir $(MPATH) -seq -digits 5 $(NAME)
migrate-up:
migrate -source file://$(MPATH) -database postgres://postgres:password@localhost:$(PORT)/postgres?sslmode=disable up $(N)
migrate-down:
migrate -source file://$(MPATH) -database postgres://postgres:password@localhost:$(PORT)/postgres?sslmode=disable down $(N)
migrate-force:
migrate -source file://$(MPATH) -database postgres://postgres:password@localhost:$(PORT)/postgres?sslmode=disable force $(VERSION)
init:
docker-compose up -d postres-account && \
$(MAKE) create-keypair ENV=dev && \
$(MAKE) create-keypair ENV=test && \
$(MAKE) migrate-down APPPATH=account N= && \
$(MAKE) migrate-up APPPATH=account N= && \
docker-compose down