1
|
#!/bin/bash
|
2
|
# Usage: (must be run from a table subdir)
|
3
|
if false; then
|
4
|
#!/bin/bash
|
5
|
cd "$(dirname "$0")"
|
6
|
. path/to/import.sh
|
7
|
|
8
|
map_table
|
9
|
psql <<'EOF'
|
10
|
postprocess_commands...
|
11
|
EOF
|
12
|
fi
|
13
|
|
14
|
import_sh_dir="$(dirname "${BASH_SOURCE[0]}")"
|
15
|
root_dir="$import_sh_dir"/..
|
16
|
bin_dir="$root_dir"/bin
|
17
|
|
18
|
table="$(basename "$PWD")"
|
19
|
schema="$(cd ..; basename "$PWD")"
|
20
|
|
21
|
psql ()
|
22
|
{
|
23
|
(echo "SET search_path TO \"$schema\", util;"; cat)|
|
24
|
env no_search_path=1 "$bin_dir"/psql_verbose_vegbien
|
25
|
}
|
26
|
|
27
|
map_table ()
|
28
|
{
|
29
|
make --directory=.. --makefile=../input.Makefile "$table"/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
|
}
|