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]}")"/table_dir.run
|
19
|
|
20
|
if self_not_included; then
|
21
|
|
22
|
map_table()
|
23
|
{
|
24
|
echo_func
|
25
|
table_make map.csv
|
26
|
psql <<EOF
|
27
|
SELECT util.reset_map_table('pg_temp.map');
|
28
|
\copy pg_temp.map FROM 'map.csv' CSV HEADER;
|
29
|
SELECT util.set_col_names('"$table"', 'pg_temp.map'::regclass);
|
30
|
EOF
|
31
|
}
|
32
|
|
33
|
mk_derived() { echo_func; "$root_dir"/schemas/VegCore/mk_derived; }
|
34
|
|
35
|
remake_VegBIEN_mappings()
|
36
|
{
|
37
|
echo_func
|
38
|
public_schema_exists || return 0
|
39
|
rm header.csv map.csv # remake them
|
40
|
yes|table_make test
|
41
|
}
|
42
|
|
43
|
postprocess() # overridable
|
44
|
{
|
45
|
echo_func
|
46
|
local file="$top_dir"/postprocess.sql
|
47
|
if test -e "$file"; then psql "$@"; fi
|
48
|
}
|
49
|
|
50
|
load_data()
|
51
|
{
|
52
|
echo_func
|
53
|
verbosity_min=3 table_make ${remake:+re}install # just the table
|
54
|
# install logs require verbose output
|
55
|
}
|
56
|
|
57
|
import()
|
58
|
{
|
59
|
echo_func
|
60
|
load_data
|
61
|
map_table
|
62
|
postprocess
|
63
|
mk_derived
|
64
|
}
|
65
|
|
66
|
fi
|