Skip to content

Commit ae28b55

Browse files
authored
Merge pull request #1443 from pnorman/quieter_migrations
Make migrations quieter.
2 parents 89007fe + f9eebd5 commit ae28b55

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

data/migrations/run_migrations.sh

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
migration_dir=${0%/*}
44

5+
PSQLOPTS="-Xq"
56
# first, run any "pre-function" migrations. these might be necessary if the
67
# migration alters tables to add columns referenced in the functions, in
78
# which case the function creation would fail.
@@ -12,24 +13,24 @@ for sql in ${migration_dir}/*.sql; do
1213
[ -f $sql ] || break
1314

1415
if [[ $sql = *prefunction*.sql ]]; then
15-
psql -f "$sql" $*
16+
psql $PSQLOPTS -f "$sql" $*
1617
else
1718
echo "SKIPPING $sql - this will be run after the functions."
1819
fi
1920
done
2021

2122
# next run functions and triggers, bailing if either of these fail, as they
2223
# 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" $*
2425
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 $*
2627
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" $*
2829
if [ $? -ne 0 ]; then echo "Installing new triggers failed.">&2; exit 1; fi
2930

3031
# then disable triggers
3132
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" $*
3334
done
3435

3536
# 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
4546
elif [[ $sql = *prefunction*.sql ]]; then
4647
echo "SKIPPING $sql - this was already run before the functions."
4748
else
48-
psql -f "$sql" $* &
49+
psql $PSQLOPTS -f "$sql" $* &
4950
fi
5051
done
5152

5253
wait
5354

5455
# re-enable triggers
5556
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" $*
5758
done
5859

5960
# re-generate the functions to avoid issues when a migration updates
6061
# 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 $*
6263
if [ $? -ne 0 ]; then echo "Installing generated functions second time failed.">&2; exit 1; fi
6364

6465
# analyze tables in case index updates influenced query plans
6566
for table in planet_osm_point planet_osm_line planet_osm_polygon; do
66-
psql -c "ANALYZE ${table}" $* &
67+
psql $PSQLOPTS -c "ANALYZE ${table}" $* &
6768
done
6869
wait
6970

data/migrations/v1.5.0-planet_osm_line.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
-- only these 2 columns are relevant in lower zoom queries
2-
CREATE INDEX
2+
SET client_min_messages TO WARNING;
3+
CREATE INDEX IF NOT EXISTS
34
planet_osm_line_geom_min_zoom_8_index
45
ON planet_osm_line USING gist(way)
56
WHERE
@@ -70,3 +71,4 @@ DROP INDEX IF EXISTS planet_osm_line_boundary_geom_index;
7071
DROP INDEX IF EXISTS planet_osm_line_boundary_geom_9_index;
7172
DROP INDEX IF EXISTS planet_osm_line_boundary_geom_12_index;
7273
DROP INDEX IF EXISTS planet_osm_line_boundary_geom_15_index;
74+
RESET client_min_messages;

data/migrations/v1.5.0-planet_osm_point.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
-- ladder the point indexes
2+
SET client_min_messages TO WARNING;
23
CREATE INDEX IF NOT EXISTS
34
planet_osm_point_geom_min_zoom_6_index
45
ON planet_osm_point USING gist(way)
@@ -68,3 +69,4 @@ DROP INDEX IF EXISTS planet_osm_point_min_zoom_places_index;
6869
DROP INDEX IF EXISTS planet_osm_point_min_zoom_places_9_index;
6970
DROP INDEX IF EXISTS planet_osm_point_min_zoom_places_12_index;
7071
DROP INDEX IF EXISTS planet_osm_point_min_zoom_places_15_index;
72+
RESET client_min_messages;

data/migrations/v1.5.0-planet_osm_polygon.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
-- polygon low zoom
2+
SET client_min_messages TO WARNING;
23
CREATE INDEX IF NOT EXISTS
34
planet_osm_polygon_geom_min_zoom_7_index
45
ON planet_osm_polygon USING gist(way)
@@ -97,3 +98,4 @@ DROP INDEX IF EXISTS planet_osm_polygon_pois_geom_6_index;
9798
DROP INDEX IF EXISTS planet_osm_polygon_pois_geom_9_index;
9899
DROP INDEX IF EXISTS planet_osm_polygon_pois_geom_12_index;
99100
DROP INDEX IF EXISTS planet_osm_polygon_pois_geom_15_index;
101+
RESET client_min_messages;

0 commit comments

Comments
 (0)