-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
64 lines (53 loc) · 2.29 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Makefile for Oakville and Milton Humane Society Project
.PHONY: lint format migration generate-migration start-docker stop-docker clean-db seed-db read-tables read-table help
# Linting & Formatting
lint:
docker exec -it humane_society_backend /bin/bash -c "yarn lint"
docker exec -it humane_society_frontend /bin/bash -c "yarn lint"
format:
docker exec -it humane_society_backend /bin/bash -c "yarn fix"
docker exec -it humane_society_frontend /bin/bash -c "yarn fix"
# Database Migrations
migration:
docker exec -it humane_society_backend /bin/bash -c "node migrate up"
generate-migration:
ifndef NAME
$(error NAME argument was not provided. Command should include a NAME parameter)
endif
docker exec -it humane_society_backend /bin/bash -c "node migrate create --name $(name).ts"
# Docker Commands
start-docker:
docker-compose up --build
stop-docker:
docker-compose down
# Database Operations
clean-db:
docker exec -it humane_society_backend /bin/bash -c "node migrate down && node migrate up"
# Seeding script has not been created yet
seed-db:
# docker exec -it humane_society_backend /bin/bash -c "node seed"
# Acessing Postgres DB
read-tables:
docker exec -it humane_society_db /bin/bash -c "\
psql -U postgres -d humane_society_dev -c '\dt';"
read-table:
ifndef TABLE
$(error TABLE argument was not provided. Command should include a TABLE parameter)
endif
docker exec -it humane_society_db /bin/bash -c "\
psql -U postgres -d humane_society_dev -c '\dt'; \
psql -U postgres -d humane_society_dev -c 'SELECT * FROM $(TABLE);'"
# Help
help:
@echo Available targets or actions:
@echo lint Lint the code
@echo format Format the code
@echo migration Run database migrations
@echo generate-migration Generate a new migration. Requires a NAME argument. Example: ```make generate-migration NAME=add-user-columns```
@echo start-docker Start Docker containers
@echo stop-docker Stop Docker containers
@echo read-tables See all database tables
@echo read-table See a single table. Requires a TABLE argument. Example: ```make read-table TABLE=users```
@echo clean-db Clean the database and rerun migrations
@echo seed-db The database seeding script has yet to be implemented
@echo help Show this help message