Postgres Upgrades: Service Code Changes

Overview

Refer below to find the changes needed in the code after Postgres is upgraded to version 14.

Steps

  1. Update the Postgresql library as given in the below snippet:

<dependency>
  <groupId>org.postgresql</groupId>
  <artifactId>postgresql</artifactId>
  <version>42.7.1</version>
</dependency>
  1. Update the flyway client library as per the details given below:

<dependency>
      <groupId>org.flywaydb</groupId>
      <artifactId>flyway-core</artifactId>
      <version>10.7.1</version>     
</dependency>
  1. Update the flyway Dockerfile and migrate.sh file as given below:

FROM egovio/flyway:10.7.1
COPY ./migration/main /flyway/sql
COPY migrate.sh /usr/bin/migrate.sh
RUN chmod +x /usr/bin/migrate.sh
ENTRYPOINT ["/usr/bin/migrate.sh"]

migrate.sh

#!/bin/sh
baseurl=$DB_URL
echo "the baseurl : $DB_URL"
schemasetter="?currentSchema="
schemas=$SCHEMA_NAME
echo "the schemas : $schemas"

# Use `tr` to replace commas with spaces for portability in `sh`
for schemaname in $(echo "$schemas" | tr ',' ' ')
do
    echo "the schema name : ${baseurl}${schemasetter}${schemaname}"
    flyway -url="${baseurl}${schemasetter}${schemaname}" \
          -table="$SCHEMA_TABLE" \
          -user="$FLYWAY_USER" \
          -password="$FLYWAY_PASSWORD" \
          -locations="$FLYWAY_LOCATIONS" \
          -baselineOnMigrate=true \
          -outOfOrder=true \
          migrate
done

Last updated

Was this helpful?