-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
84 lines (74 loc) · 3.19 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
PROJECT_NAME := my_vocab_backend
DC := docker compose
MIGRATIONS_DIR := ./app/db/migrations/versions
ENVIRONMENTS := prod dev test
validate-env: # arguments: env(str=prod|dev|test);
echo "${ENVIRONMENTS}" | rg -w --quiet "${env}"; \
if [ $$? -ne 0 ]; \
then \
echo; \
echo "┌────────────────────────────────────"; \
echo "| Validation error:"; \
echo "| Environment must be one of [${ENVIRONMENTS}], actual=${env}"; \
echo "└────────────────────────────────────"; \
echo; \
exit 1; \
fi
dc: # arguments: env(str=prod|dev|test), args(str, passed to dc-up);
make validate-env env="${env}"
${DC} -f "docker-compose.${env}.yaml" --project-name "${PROJECT_NAME}_${env}" up ${args}
dc-down: # arguments: env(str=prod|dev|test);
make validate-env env="${env}"
${DC} -f "docker-compose.${env}.yaml" --project-name "${PROJECT_NAME}_${env}" down -v --rmi local
prod:
make dc env=prod
prod-down:
make dc-down env=prod
dev:
make dc env=dev
dev-down:
make dc-down env=dev
test:
make dc env="test" args="--abort-on-container-exit --exit-code-from test"
test-down:
make dc-down env=test
lint:
./scripts/lint.sh
local-test:
./scripts/full_test.sh
rm-mypy-cache:
rm -rf .mypy_cache/
clean:
make prod-down
make dev-down
make test-down
make rm-mypy-cache
migration: # arguments: message(str);
alembic revision --autogenerate -m ${message}
migrate:
alembic upgrade head
downgrade:
alembic downgrade base
rm-migrations:
rm ${MIGRATIONS_DIR}/*.py
dangerous-remigrate:
make downgrade
@echo "┌────────────────────────────────────┐"
@echo "│ DB has been cleared │"
@echo "└────────────────────────────────────┘"
make rm-migrations
@echo "┌────────────────────────────────────┐"
@echo "│ Old migrations have been deleted │"
@echo "└────────────────────────────────────┘"
make migration message="init"
@echo "┌────────────────────────────────────┐"
@echo "│ Init migration has been made │"
@echo "└────────────────────────────────────┘"
./scripts/add_enums_drop_to_migration.sh
@echo "┌────────────────────────────────────┐"
@echo "│ Enums drop have been fixed │"
@echo "└────────────────────────────────────┘"
make migrate
@echo "┌────────────────────────────────────┐"
@echo "│ Migration has been migrated │"
@echo "└────────────────────────────────────┘"