Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add warning when PGVERSION differs

Oliver Günther43f91b0fb750
diff --git a/docker/prod/entrypoint.sh b/docker/prod/entrypoint.sh
index 546c102b3dd..8b4065cba3a 100755
--- a/docker/prod/entrypoint.sh
+++ b/docker/prod/entrypoint.sh
@@ -30,8 +30,19 @@ if [ "$(id -u)" = '0' ]; then
# reexport PGVERSION and PGBIN env variables according to postgres version of existing cluster (if any)
# this must happen in the entrypoint
if [ -f "$PGDATA/PG_VERSION" ]; then
- export PGVERSION="$(cat "$PGDATA/PG_VERSION")"
+ EXISTING_PGVERSION="$(cat "$PGDATA/PG_VERSION")"
echo "-----> Existing PostgreSQL cluster found in $PGDATA."
+
+ # Check for version mismatch: if Docker default is PG 17 but existing data is PG 13
+ if [ "$PGVERSION" = "17" ] && [ "$EXISTING_PGVERSION" = "13" ]; then
+ echo "WARNING: PostgreSQL version mismatch detected!"
+ echo "Your container is configured for PostgreSQL 17, but existing data is from PostgreSQL 13."
+ echo "You need to upgrade your postgresql data before you can use it with PGVERSION=17 in the container"
+ echo "Please see the migration guide: https://www.openproject.org/docs/installation-and-operations/misc/migration-to-postgresql17/"
+ echo "Continuing with PostgreSQL 13 for now..."
+ fi
+
+ export PGVERSION="$EXISTING_PGVERSION"
fi
export PGBIN="/usr/lib/postgresql/$PGVERSION/bin"
export PGCONF_FILE="/etc/postgresql/$PGVERSION/main/postgresql.conf"