Skip to content

Commit

Permalink
If a VERSION file does not exist in the data director, but existing d…
Browse files Browse the repository at this point in the history
…ata directories exist,

print an error and exit.

We no longer have the postgres 9 packages to be able to upgrade from these versions. Users will
have to upgrade to an older first first.
  • Loading branch information
jpalermo committed Aug 11, 2023
1 parent 16014c5 commit b7cba29
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions jobs/postgres/templates/pre-start.sh.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,12 @@ function main() {
chmod 700 "${PG_STORE_DIR}"

if [ ! -f ${VERSION_FILE} ]; then
for version in "postgres-9.6.8" "postgres-9.6.6" "postgres-9.6.4"; do
if [[ -d "${PG_STORE_DIR}/${version}" ]]; then
if [[ -f "${PG_STORE_DIR}/${version}/postgresql.conf" ]]; then
echo "Creating the PostgreSQL data version file at version ${version}"
echo ${version} > ${VERSION_FILE}
chown -R vcap:vcap "${VERSION_FILE}"
chmod 700 "${VERSION_FILE}"
pgversion_upgrade_from=${version}
DATA_DIR_OLD="${PG_STORE_DIR}/${version}"
PACKAGE_DIR_OLD=/var/vcap/packages/${version}
break
fi
fi
done
existing_data_dirs=$(compgen -G "${PG_STORE_DIR}/postgres-*")

if [ -n "${existing_data_dirs}" ]; then
echo "Found existing data dirs that we cannot upgrade from in this release. Upgrade to and older version first."
exit 1
fi
fi

mkdir -p "${LOG_DIR}"
Expand Down

0 comments on commit b7cba29

Please sign in to comment.