Skip to content

Commit ebaf443

Browse files
authored
feat: covering ranges for upgrades (#1603)
* feat: need to cover less than or equal to 15 * feat: handle range of 16 or greater for destination of upgrade * feat: use -ge approach for all instances of 16+ handling * chore: testing vers bump * chore: version bump for release
1 parent 413a82d commit ebaf443

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ POST_UPGRADE_EXTENSION_SCRIPT="/tmp/pg_upgrade/pg_upgrade_extensions.sql"
4343
POST_UPGRADE_POSTGRES_PERMS_SCRIPT="/tmp/pg_upgrade/pg_upgrade_postgres_perms.sql"
4444
OLD_PGVERSION=$(run_sql -A -t -c "SHOW server_version;")
4545

46-
# Skip locale settings if both versions are PostgreSQL 17+
47-
if ! [[ "$OLD_PGVERSION" =~ ^17.* && "$PGVERSION" =~ ^17.* ]]; then
46+
# Skip locale settings if both versions are PostgreSQL 16+
47+
if ! [[ "${OLD_PGVERSION%%.*}" -ge 16 && "${PGVERSION%%.*}" -ge 16 ]]; then
4848
SERVER_LC_COLLATE=$(run_sql -A -t -c "SHOW lc_collate;")
4949
SERVER_LC_CTYPE=$(run_sql -A -t -c "SHOW lc_ctype;")
5050
fi
@@ -403,7 +403,7 @@ function initiate_upgrade {
403403
rm -rf "${PGDATANEW:?}/"
404404

405405
if [ "$IS_NIX_UPGRADE" = "true" ]; then
406-
if [[ "$PGVERSION" =~ ^17.* ]]; then
406+
if [[ "${PGVERSION%%.*}" -ge 16 ]]; then
407407
LC_ALL=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LANGUAGE=en_US.UTF-8 LANG=en_US.UTF-8 LOCALE_ARCHIVE=/usr/lib/locale/locale-archive su -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && $PGBINNEW/initdb --encoding=$SERVER_ENCODING --locale-provider=icu --icu-locale=en_US.UTF-8 -L $PGSHARENEW -D $PGDATANEW/ --username=supabase_admin" -s "$SHELL" postgres
408408
else
409409
LC_ALL=en_US.UTF-8 LC_CTYPE=$SERVER_LC_CTYPE LC_COLLATE=$SERVER_LC_COLLATE LANGUAGE=en_US.UTF-8 LANG=en_US.UTF-8 LOCALE_ARCHIVE=/usr/lib/locale/locale-archive su -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && $PGBINNEW/initdb --encoding=$SERVER_ENCODING --lc-collate=$SERVER_LC_COLLATE --lc-ctype=$SERVER_LC_CTYPE -L $PGSHARENEW -D $PGDATANEW/ --username=supabase_admin" -s "$SHELL" postgres
@@ -430,8 +430,8 @@ $(cat /etc/postgresql/pg_hba.conf)" > /etc/postgresql/pg_hba.conf
430430
# Add the setting if not found
431431
echo "max_slot_wal_keep_size = -1" >> "$TMP_CONFIG"
432432

433-
# Remove db_user_namespace if upgrading from PG15
434-
if [[ "$OLD_PGVERSION" =~ ^15.* && "$PGVERSION" =~ ^17.* ]]; then
433+
# Remove db_user_namespace if upgrading from PG15 or lower to PG16+
434+
if [[ "${OLD_PGVERSION%%.*}" -le 15 && "${PGVERSION%%.*}" -ge 16 ]]; then
435435
sed -i '/^db_user_namespace/d' "$TMP_CONFIG"
436436
fi
437437

@@ -457,7 +457,7 @@ EOF
457457
UPGRADE_COMMAND=". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && $UPGRADE_COMMAND"
458458
fi
459459

460-
if [[ "$PGVERSION" =~ ^17.* ]]; then
460+
if [[ "${PGVERSION%%.*}" -ge 16 ]]; then
461461
GRN_PLUGINS_DIR=/var/lib/postgresql/.nix-profile/lib/groonga/plugins LC_ALL=en_US.UTF-8 LANGUAGE=en_US.UTF-8 LANG=en_US.UTF-8 LOCALE_ARCHIVE=/usr/lib/locale/locale-archive su -pc "$UPGRADE_COMMAND --check" -s "$SHELL" postgres
462462
else
463463
GRN_PLUGINS_DIR=/var/lib/postgresql/.nix-profile/lib/groonga/plugins LC_ALL=en_US.UTF-8 LC_CTYPE=$SERVER_LC_CTYPE LC_COLLATE=$SERVER_LC_COLLATE LANGUAGE=en_US.UTF-8 LANG=en_US.UTF-8 LOCALE_ARCHIVE=/usr/lib/locale/locale-archive su -pc "$UPGRADE_COMMAND --check" -s "$SHELL" postgres
@@ -479,7 +479,7 @@ EOF
479479
fi
480480

481481
# Start the old PostgreSQL instance with version-specific options
482-
if [[ "$PGVERSION" =~ ^17.* ]]; then
482+
if [[ "${PGVERSION%%.*}" -ge 16 ]]; then
483483
GRN_PLUGINS_DIR=/var/lib/postgresql/.nix-profile/lib/groonga/plugins LC_ALL=en_US.UTF-8 LANGUAGE=en_US.UTF-8 LANG=en_US.UTF-8 LOCALE_ARCHIVE=/usr/lib/locale/locale-archive su -pc "$UPGRADE_COMMAND" -s "$SHELL" postgres
484484
else
485485
GRN_PLUGINS_DIR=/var/lib/postgresql/.nix-profile/lib/groonga/plugins LC_ALL=en_US.UTF-8 LC_CTYPE=$SERVER_LC_CTYPE LC_COLLATE=$SERVER_LC_COLLATE LANGUAGE=en_US.UTF-8 LANG=en_US.UTF-8 LOCALE_ARCHIVE=/usr/lib/locale/locale-archive su -pc "$UPGRADE_COMMAND" -s "$SHELL" postgres

ansible/vars.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ postgres_major:
99

1010
# Full version strings for each major version
1111
postgres_release:
12-
postgresorioledb-17: "17.0.1.085-orioledb"
13-
postgres17: "17.4.1.035"
14-
postgres15: "15.8.1.092"
12+
postgresorioledb-17: "17.0.1.086-orioledb"
13+
postgres17: "17.4.1.036"
14+
postgres15: "15.8.1.093"
1515

1616
# Non Postgres Extensions
1717
pgbouncer_release: "1.19.0"

0 commit comments

Comments
 (0)