Project

General

Profile

1
#!/bin/bash -e
2

    
3
if false; then #### run script template:
4
#!/bin/bash -e
5
. "$(dirname "${BASH_SOURCE[0]}")"/path/to/table.run
6

    
7
func_override import__table_run
8
import()
9
{
10
	echo_func
11
	before_import_cmds
12
	import__table_run "$@"
13
	after_import_cmds
14
}
15
fi ####
16

    
17
. "$(dirname "${BASH_SOURCE[0]}")"/import.run
18
. "$(dirname "${BASH_SOURCE[0]}")"/subdir.run
19

    
20
if self_not_included; then
21

    
22
: "${table=$subdir}"; export table
23

    
24
table_make() { subdir_make "$@"; }
25

    
26
map_table()
27
{
28
	echo_func
29
	table_make map.csv
30
	psql <<EOF
31
SELECT util.reset_map_table('pg_temp.map');
32
\copy pg_temp.map FROM 'map.csv' CSV HEADER;
33
SELECT util.set_col_names('"$table"', 'pg_temp.map'::regclass);
34
EOF
35
}
36

    
37
mk_derived() { echo_func; "$root_dir"/schemas/VegCore/mk_derived; }
38

    
39
remake_VegBIEN_mappings()
40
{
41
	echo_func
42
	public_schema_exists || return 0
43
	rm header.csv map.csv # remake them
44
	yes|table_make test
45
}
46

    
47
postprocess() # overridable
48
{
49
	echo_func
50
	local file="$top_dir"/postprocess.sql
51
	if test -e "$file"; then psql "$@"; fi
52
}
53

    
54
load_data()
55
{
56
	echo_func
57
	verbosity_min=3 table_make ${remake:+re}install # just the table
58
		# install logs require verbose output
59
}
60

    
61
import()
62
{
63
	echo_func
64
	load_data
65
	map_table
66
	postprocess
67
	mk_derived
68
}
69

    
70
fi
(4-4/5)