-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
72 lines (44 loc) · 1.84 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
PATH := node_modules/.bin:$(PATH)
default: db/all
define EXPAND_EXPORTS
export $(word 1, $(subst =, , $(1))) := $(word 2, $(subst =, , $(1)))
endef
# expand PG* environment vars
$(foreach a,$(shell set -a; node_modules/.bin/pgexplode),$(eval $(call EXPAND_EXPORTS,$(a))))
define create_relation
@psql -v ON_ERROR_STOP=1 -qXc "\d $(subst db/,,$@)" > /dev/null 2>&1 || \
psql -v ON_ERROR_STOP=1 -qX1f sql/$(subst db/,,$@).sql
endef
define register_relation_target
.PHONY: db/$(strip $(1))
db/$(strip $(1)): db
$$(call create_relation)
endef
$(foreach fn,$(shell ls sql/ 2> /dev/null | sed 's/\..*//'),$(eval $(call register_relation_target,$(fn))))
.PHONY: DATABASE_URL
DATABASE_URL:
@test "${$@}" || (echo "$@ is undefined" && false)
.PHONY: db
db: DATABASE_URL
@psql -c "SELECT 1" > /dev/null 2>&1 || \
createdb
db/all: db/augmented_diff_status db/badges db/badges_users db/badge_updater_status db/changesets_status db/changesets db/changesets_countries db/changesets_hashtags db/countries db/hashtags db/hashtag_stats db/raw_changesets_countries db/raw_changesets_hashtags db/raw_changesets db/raw_countries db/raw_countries_users db/raw_hashtags db/raw_hashtags_users db/raw_users db/user_stats db/users
db/changesets: db/raw_changesets
db/changesets_countries: db/raw_changesets_countries
db/changesets_hashtags: db/raw_changesets_hashtags
db/countries: db/raw_countries
db/hashtags: db/raw_hashtags
db/hashtag_stats: db/raw_changesets_hashtags db/raw_changesets db/raw_hashtags
db/raw_hashtags_users: db/raw_changesets db/raw_changesets_hashtags
db/raw_countries_users: db/raw_changesets db/raw_changesets_countries
db/user_stats: db/raw_changesets
db/users: db/raw_users
.PHONY: housekeeping
housekeeping:
npm run housekeeping
.PHONY: osm-changes
osm-changes:
npm run osm-changes
.PHONY: update-badges
update-badges:
npm run update-badges