22 lines
1.0 KiB
Makefile
22 lines
1.0 KiB
Makefile
SHELL := /bin/bash
|
|
|
|
TABLES = stops
|
|
|
|
SCHEMA = zhv
|
|
|
|
psql = $(strip psql -v schema=$(SCHEMA))
|
|
|
|
# $(addprefix prefix,names…): The argument names is regarded as a series of names, separated by whitespace; prefix is used as a unit. The value of prefix is prepended to the front of each individual name and the resulting larger names are concatenated with single spaces between them.
|
|
#
|
|
# FORMAT(format_string [, format_arg [, ...] ])
|
|
load: $(addprefix load-,$(TABLES))
|
|
@$(psql) -t -A -c "SELECT FORMAT('* loaded %s', feed_file) WHERE feed_file = '$(GTFS)';"
|
|
|
|
copy: $(ZHV)
|
|
$(psql) -c "\copy zhv.stops(stop_seq_no,stop_type,stop_dhid,stop_parent,stop_name,stop_lat,stop_lon,stop_municipality_code,stop_municipality,stop_district_code,stop_district,stop_condition,stop_state,stop_description,stop_authority,stop_delfi_name,stop_tariff_dhid,stop_tariff_name) FROM '$<' DELIMITER ';' CSV HEADER;"
|
|
|
|
# -v: variable assignment, like the /set meta-command
|
|
# $<: name of the firest prerequisite
|
|
init: sql/schema.sql
|
|
$(psql) -v ON_ERROR_STOP=on -f $<
|