forked from open-data/ckanext-canada
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
51 lines (41 loc) · 1.92 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
CKAN_CONFIG ?= development.ini
DB_TEMPLATE ?= test_template
ifeq ($(wildcard ${CKAN_CONFIG}),)
$(error CKAN configuration file ${CKAN_CONFIG} not found, you may \
want to specify an override for the CKAN_CONFIG value)
endif
PSQL_COMMAND = $(shell bin/psql_args.py ${CKAN_CONFIG})
DB_NAME_PORT = $(shell bin/psql_dbname.py ${CKAN_CONFIG})
DB_USER = $(shell bin/psql_user.py ${CKAN_CONFIG})
POSTGIS = $(firstword $(wildcard \
/usr/share/pgsql/contrib/postgis-64.sql \
/usr/share/postgresql/*/contrib/postgis-1.5/postgis.sql \
))
SPATIAL_REF_SYS = $(firstword $(wildcard \
/usr/share/pgsql/contrib/postgis-1.5/spatial_ref_sys.sql \
/usr/share/postgresql/*/contrib/postgis-1.5/spatial_ref_sys.sql \
))
test: reset-database
nosetests --with-pylons=${CKAN_CONFIG} --nologcapture ckanext/canada/tests 2>&1
drop-database:
-sudo -u postgres dropdb ${DB_NAME_PORT}
build-database: drop-database
sudo -u postgres createdb ${DB_NAME_PORT} -O ${DB_USER} -E UTF-8
sudo -u postgres psql ${DB_NAME_PORT} < ${POSTGIS}
sudo -u postgres psql ${DB_NAME_PORT} -c "ALTER TABLE spatial_ref_sys OWNER TO ${DB_USER}"
sudo -u postgres psql ${DB_NAME_PORT} -c "ALTER TABLE geometry_columns OWNER TO ${DB_USER}"
bash -c "${PSQL_COMMAND}" < ${SPATIAL_REF_SYS}
paster --plugin=ckan db init -c ${CKAN_CONFIG}
paster --plugin=ckan search-index clear -c ${CKAN_CONFIG}
paster canada create-vocabularies -c ${CKAN_CONFIG}
paster canada create-organizations -c ${CKAN_CONFIG}
paster --plugin=ckan sysadmin add admin -c ${CKAN_CONFIG}
tune-database:
bash -c "${PSQL_COMMAND}" < tuning/constraints.sql
bash -c "${PSQL_COMMAND}" < tuning/what_to_alter.sql
build-database-template: drop-database build-database
-sudo -u postgres dropdb ${DB_TEMPLATE} \
$(wordlist 2, 3, ${DB_NAME_PORT})
sudo -u postgres createdb ${DB_TEMPLATE} -T ${DB_NAME_PORT}
reset-database: drop-database
sudo -u postgres createdb ${DB_NAME_PORT} -T ${DB_TEMPLATE}