File tree Expand file tree Collapse file tree 4 files changed +20
-5
lines changed Expand file tree Collapse file tree 4 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ The complete list of available properties can be found in the [spec](jobs/postgr
76
76
77
77
Property | Description
78
78
-------- | -------------
79
- databases.version | Define the used PostgreSQL major version. Default: 15
79
+ databases.version | Define the used PostgreSQL major version. Default: 16
80
80
databases.port | The database port. Default: 5432
81
81
databases.databases | A list of databases and associated properties to create when Postgres starts
82
82
databases.databases[ n] .name | Database name
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ provides:
46
46
properties:
47
47
databases.version:
48
48
description: "The database version e.g. 11, 13, 15 or 16"
49
- default: "16"
49
+ default: 16
50
50
databases.port:
51
51
description: "The database port"
52
52
default: 5432
Original file line number Diff line number Diff line change @@ -68,6 +68,13 @@ function is_major() {
68
68
[ " ${pgversion_current% .* } " != " ${pgversion_upgrade_from% .* } " ]
69
69
}
70
70
71
+ function check_postgresql_versions(){
72
+ if [[ $( echo -e " $pgversion_upgrade_from \n$pgversion_current " | sort --version-sort | head --lines=1) != $pgversion_upgrade_from ]]; then
73
+ echo " The downgrade of the database instance is not supported."
74
+ exit 1
75
+ fi
76
+ }
77
+
71
78
function init_data_dir(){
72
79
if [ ! -f " ${DATA_DIR} /postgresql.conf" ]; then
73
80
# initdb creates data directories
@@ -77,7 +84,7 @@ function init_data_dir(){
77
84
}
78
85
79
86
function run_major_upgrade(){
80
- if is_major; then
87
+ if is_major && check_postgresql_versions ; then
81
88
rm -rf ${DATA_DIR_PREVIOUS}
82
89
echo " Running a PostgreSQL major upgrade from ${pgversion_upgrade_from} to ${pgversion_current} "
83
90
touch " $POSTGRES_UPGRADE_LOCK "
105
112
fi
106
113
}
107
114
function run_minor_upgrade(){
108
- if ! is_major; then
115
+ if ! is_major && check_postgresql_versions ; then
109
116
rm -rf ${DATA_DIR_PREVIOUS}
110
117
echo " Running a PostgreSQL minor upgrade from ${pgversion_upgrade_from} to ${pgversion_current} "
111
118
< % if p(" databases.skip_data_copy_in_minor" ) %>
Original file line number Diff line number Diff line change @@ -5,10 +5,18 @@ pgversion_current=$2
5
5
# From postgres-x.y.z, it's major if x and y are not the same
6
6
# in $pgversion_current and $pgversion_upgrade_from
7
7
8
+ function check_postgresql_versions(){
9
+ if [[ $( echo -e " $pgversion_upgrade_from \n$pgversion_current " | sort --version-sort | head --lines=1) != $pgversion_upgrade_from ]]; then
10
+ echo " The downgrade of the database instance is not supported."
11
+ exit 1
12
+ fi
13
+ }
14
+
8
15
function is_major() {
9
16
[ " ${pgversion_current% .* } " != " ${pgversion_upgrade_from% .* } " ]
10
17
}
11
- if is_major; then
18
+
19
+ if is_major && check_postgresql_versions; then
12
20
echo is major
13
21
else
14
22
echo is minor
You can’t perform that action at this time.
0 commit comments