forked from globocom/database-as-a-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
93 lines (57 loc) · 2.56 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
85
86
87
88
89
90
91
92
.PHONY: default clean pip test run
define CHECK_SCRIPT
import sys
if sys.getdefaultencoding() != "utf-8":
print "Configure python default encoding to UTF-8"
sys.exit(1)
endef
export CHECK_SCRIPT
# Use make -e DBAAS_DATABASE_HOST=another_host to replace default value
default:
@awk -F\: '/^[a-z_]+:/ && !/default/ {printf "- %-20s %s\n", $$1, $$2}' Makefile
clean: # remove temporary files
@find . -name \*.pyc -delete
@find . -name \*.orig -delete
@find . -name \*.bak -delete
@find . -name __pycache__ -delete
@find . -name coverage.xml -delete
@find . -name test-report.xml -delete
@find . -name .coverage -delete
check_environment: # check if your local environment is ok to running this project
@echo "$$CHECK_SCRIPT" | python -
pip: # install pip libraries
@pip install -r requirements.txt
@pip install -r requirements_test.txt
compile:
@find . -name "*.py" -exec python -m py_compile {} +
db_reset: # drop and create database
@mysqladmin -uroot -p$(DBAAS_DATABASE_PASSWORD) -f drop dbaas -hlocalhost; true
@mysqladmin -uroot -p$(DBAAS_DATABASE_PASSWORD) create dbaas -hlocalhost
@cd dbaas && python manage.py syncdb --migrate --noinput
load_basic_roles: # load roles
@cd dbaas && python manage.py loaddata basic_roles.yaml
load_basic_configs: # load roles
@cd dbaas && python manage.py loaddata basic_configs.yaml
reset_data: db_reset # drop and create database and insert sample data
@cd dbaas && python manage.py sample_data
@cd dbaas && python manage.py loaddata basic_roles.yaml
@cd dbaas && python manage.py loaddata basic_configs.yaml
run_migrate: # run all migrations
@cd dbaas && python manage.py syncdb --migrate --noinput
test: # run tests
@mysqladmin -uroot -p$(DBAAS_DATABASE_PASSWORD) -f drop test_dbaas -h$(DBAAS_DATABASE_HOST); true
@cd dbaas && python manage.py test --traceback $(filter-out $@,$(MAKECMDGOALS))
run: # run local server
@cd dbaas && python manage.py runserver 0.0.0.0:8000 $(filter-out $@,$(MAKECMDGOALS))
shell: # run django shell
@cd dbaas && python manage.py shell_plus --use-pythonrc
update_permissions:
@cd dbaas && python manage.py update_permissions
physical_migrate: # create migration to physical app
@cd dbaas && python manage.py schemamigration physical --auto
tsuru_migrate: # create migration to tsuru app
@cd dbaas && python manage.py schemamigration tsuru --auto
logical_migrate: # create migration to logical app
@cd dbaas && python manage.py schemamigration logical --auto
graph_models: # generate graph models
@cd dbaas && python manage.py graph_models -g physical logical tsuru > ~/dbaas_model.dot