5
5
# # The following commands copy custom PG configs and enable previously disabled
6
6
# # extensions, containing regtypes referencing system OIDs.
7
7
8
- # Extensions to be reenabled after pg_upgrade.
9
- # Running an upgrade with these extensions enabled will result in errors due to
10
- # them depending on regtypes referencing system OIDs. Thus they have been disabled
11
- # beforehand.
12
- EXTENSIONS_TO_REENABLE=(
13
- " pg_graphql"
14
- )
15
-
16
8
set -eEuo pipefail
17
9
18
10
run_sql () {
@@ -23,9 +15,9 @@ cleanup() {
23
15
UPGRADE_STATUS=${1:- " failed" }
24
16
EXIT_CODE=${?:- 0}
25
17
26
- echo " ${ UPGRADE_STATUS} " > /tmp/pg-upgrade-status
18
+ echo " $UPGRADE_STATUS " > /tmp/pg-upgrade-status
27
19
28
- exit $EXIT_CODE
20
+ exit " $EXIT_CODE "
29
21
}
30
22
31
23
function complete_pg_upgrade {
@@ -36,37 +28,39 @@ function complete_pg_upgrade {
36
28
37
29
echo " running" > /tmp/pg-upgrade-status
38
30
31
+ echo " 1. Mounting data disk"
39
32
mount -a -v
40
33
41
34
# copying custom configurations
35
+ echo " 2. Copying custom configurations"
42
36
cp -R /data/conf/* /etc/postgresql-custom/
43
37
chown -R postgres:postgres /var/lib/postgresql/data
44
38
chown -R postgres:postgres /data/pgdata
45
39
40
+ echo " 3. Starting postgresql"
46
41
service postgresql start
47
42
48
- for EXTENSION in " ${EXTENSIONS_TO_REENABLE[@]} " ; do
49
- run_sql -c " CREATE EXTENSION IF NOT EXISTS ${EXTENSION} CASCADE;"
50
- done
51
-
43
+ echo " 4. Running generated SQL files"
52
44
if [ -d /data/sql ]; then
53
45
for FILE in /data/sql/* .sql; do
54
46
if [ -f " $FILE " ]; then
55
- run_sql -f $FILE
47
+ run_sql -f " $FILE "
56
48
fi
57
49
done
58
50
fi
59
51
60
52
sleep 5
53
+
54
+ echo " 5. Restarting postgresql"
61
55
service postgresql restart
62
56
57
+ echo " 6. Starting vacuum analyze"
63
58
start_vacuum_analyze
64
-
65
- echo " Upgrade job completed"
66
59
}
67
60
68
61
function start_vacuum_analyze {
69
- su -c ' vacuumdb --all --analyze-in-stages' -s $SHELL postgres
62
+ su -c ' vacuumdb --all --analyze-in-stages' -s " $SHELL " postgres
63
+ echo " Upgrade job completed"
70
64
cleanup " complete"
71
65
}
72
66
0 commit comments