1 |
8291
|
aaronmk
|
#!/bin/bash -e
|
2 |
8273
|
aaronmk
|
|
3 |
|
|
if false; then #### run script template:
|
4 |
8291
|
aaronmk
|
#!/bin/bash -e
|
5 |
8273
|
aaronmk
|
. "$(dirname "${BASH_SOURCE[0]}")"/path/to/table.run
|
6 |
8161
|
aaronmk
|
|
7 |
9039
|
aaronmk
|
func_override import__table_run
|
8 |
9074
|
aaronmk
|
import()
|
9 |
8273
|
aaronmk
|
{
|
10 |
8881
|
aaronmk
|
echo_func
|
11 |
8273
|
aaronmk
|
before_import_cmds
|
12 |
9039
|
aaronmk
|
import__table_run "$@"
|
13 |
8273
|
aaronmk
|
after_import_cmds
|
14 |
|
|
}
|
15 |
|
|
fi ####
|
16 |
8213
|
aaronmk
|
|
17 |
8296
|
aaronmk
|
. "$(dirname "${BASH_SOURCE[0]}")"/import.run
|
18 |
9555
|
aaronmk
|
. "$(dirname "${BASH_SOURCE[0]}")"/table_dir.run
|
19 |
8273
|
aaronmk
|
|
20 |
8705
|
aaronmk
|
if self_not_included; then
|
21 |
|
|
|
22 |
9074
|
aaronmk
|
map_table()
|
23 |
8161
|
aaronmk
|
{
|
24 |
8881
|
aaronmk
|
echo_func
|
25 |
9386
|
aaronmk
|
table_make map.csv
|
26 |
8214
|
aaronmk
|
psql <<EOF
|
27 |
8191
|
aaronmk
|
SELECT util.reset_map_table('pg_temp.map');
|
28 |
8161
|
aaronmk
|
\copy pg_temp.map FROM 'map.csv' CSV HEADER;
|
29 |
8191
|
aaronmk
|
SELECT util.set_col_names('"$table"', 'pg_temp.map'::regclass);
|
30 |
8161
|
aaronmk
|
EOF
|
31 |
|
|
}
|
32 |
8198
|
aaronmk
|
|
33 |
9350
|
aaronmk
|
mk_derived() { echo_func; "$root_dir"/schemas/VegCore/mk_derived; }
|
34 |
8245
|
aaronmk
|
|
35 |
9074
|
aaronmk
|
remake_VegBIEN_mappings()
|
36 |
8245
|
aaronmk
|
{
|
37 |
8881
|
aaronmk
|
echo_func
|
38 |
9047
|
aaronmk
|
public_schema_exists || return 0
|
39 |
9169
|
aaronmk
|
rm header.csv map.csv # remake them
|
40 |
9386
|
aaronmk
|
yes|table_make test
|
41 |
8245
|
aaronmk
|
}
|
42 |
8273
|
aaronmk
|
|
43 |
9074
|
aaronmk
|
postprocess() # overridable
|
44 |
8273
|
aaronmk
|
{
|
45 |
8881
|
aaronmk
|
echo_func
|
46 |
8273
|
aaronmk
|
local file="$top_dir"/postprocess.sql
|
47 |
|
|
if test -e "$file"; then psql "$@"; fi
|
48 |
|
|
}
|
49 |
|
|
|
50 |
9392
|
aaronmk
|
load_data()
|
51 |
|
|
{
|
52 |
|
|
echo_func
|
53 |
9408
|
aaronmk
|
verbosity_min=3 table_make ${remake:+re}install # just the table
|
54 |
|
|
# install logs require verbose output
|
55 |
9392
|
aaronmk
|
}
|
56 |
|
|
|
57 |
9074
|
aaronmk
|
import()
|
58 |
8273
|
aaronmk
|
{
|
59 |
8881
|
aaronmk
|
echo_func
|
60 |
9392
|
aaronmk
|
load_data
|
61 |
8282
|
aaronmk
|
map_table
|
62 |
|
|
postprocess
|
63 |
|
|
mk_derived
|
64 |
8273
|
aaronmk
|
}
|
65 |
8705
|
aaronmk
|
|
66 |
|
|
fi
|