2
2
3
3
migration_dir=${0%/* }
4
4
5
+ PSQLOPTS=" -Xq"
5
6
# first, run any "pre-function" migrations. these might be necessary if the
6
7
# migration alters tables to add columns referenced in the functions, in
7
8
# which case the function creation would fail.
@@ -12,24 +13,24 @@ for sql in ${migration_dir}/*.sql; do
12
13
[ -f $sql ] || break
13
14
14
15
if [[ $sql = * prefunction* .sql ]]; then
15
- psql -f " $sql " $*
16
+ psql $PSQLOPTS -f " $sql " $*
16
17
else
17
18
echo " SKIPPING $sql - this will be run after the functions."
18
19
fi
19
20
done
20
21
21
22
# next run functions and triggers, bailing if either of these fail, as they
22
23
# are required by later steps.
23
- psql --set ON_ERROR_STOP=1 -f " ${migration_dir} /../functions.sql" $*
24
+ psql $PSQLOPTS --set ON_ERROR_STOP=1 -f " ${migration_dir} /../functions.sql" $*
24
25
if [ $? -ne 0 ]; then echo " Installing new functions failed." >&2 ; exit 1; fi
25
- python ${migration_dir} /../../vectordatasource/meta/sql.py | psql --set ON_ERROR_STOP=1 $*
26
+ python ${migration_dir} /../../vectordatasource/meta/sql.py | psql $PSQLOPTS --set ON_ERROR_STOP=1 $*
26
27
if [ $? -ne 0 ]; then echo " Installing generated functions failed." >&2 ; exit 1; fi
27
- psql --set ON_ERROR_STOP=1 -f " ${migration_dir} /../triggers.sql" $*
28
+ psql $PSQLOPTS --set ON_ERROR_STOP=1 -f " ${migration_dir} /../triggers.sql" $*
28
29
if [ $? -ne 0 ]; then echo " Installing new triggers failed." >&2 ; exit 1; fi
29
30
30
31
# then disable triggers
31
32
for table in planet_osm_point planet_osm_line planet_osm_polygon planet_osm_rels; do
32
- psql -c " ALTER TABLE ${table} DISABLE TRIGGER USER" $*
33
+ psql $PSQLOPTS -c " ALTER TABLE ${table} DISABLE TRIGGER USER" $*
33
34
done
34
35
35
36
# run updates in parallel. note that we don't bail here, as we want to
@@ -45,25 +46,25 @@ for sql in ${migration_dir}/*.sql; do
45
46
elif [[ $sql = * prefunction* .sql ]]; then
46
47
echo " SKIPPING $sql - this was already run before the functions."
47
48
else
48
- psql -f " $sql " $* &
49
+ psql $PSQLOPTS -f " $sql " $* &
49
50
fi
50
51
done
51
52
52
53
wait
53
54
54
55
# re-enable triggers
55
56
for table in planet_osm_point planet_osm_line planet_osm_polygon planet_osm_rels; do
56
- psql -c " ALTER TABLE ${table} ENABLE TRIGGER USER" $*
57
+ psql $PSQLOPTS -c " ALTER TABLE ${table} ENABLE TRIGGER USER" $*
57
58
done
58
59
59
60
# re-generate the functions to avoid issues when a migration updates
60
61
# the schema
61
- python ${migration_dir} /../../vectordatasource/meta/sql.py | psql --set ON_ERROR_STOP=1 $*
62
+ python ${migration_dir} /../../vectordatasource/meta/sql.py | psql $PSQLOPTS --set ON_ERROR_STOP=1 $*
62
63
if [ $? -ne 0 ]; then echo " Installing generated functions second time failed." >&2 ; exit 1; fi
63
64
64
65
# analyze tables in case index updates influenced query plans
65
66
for table in planet_osm_point planet_osm_line planet_osm_polygon; do
66
- psql -c " ANALYZE ${table} " $* &
67
+ psql $PSQLOPTS -c " ANALYZE ${table} " $* &
67
68
done
68
69
wait
69
70
0 commit comments