From 6d4ba25658c402ba2d6e2f7c60da2c158c613a37 Mon Sep 17 00:00:00 2001 From: Cyril Rohr Date: Mon, 9 Nov 2026 15:17:46 +0100 Subject: [PATCH 1/2] Default new databases to PostgreSQL 18 with pgvector --- .env.example | 2 +- CHANGELOG.md | 11 +++++++++++ README.md | 20 ++++++++++++++++++++ docker-compose.yml | 11 +++-------- postgres/init-vector.sh | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 68 insertions(+), 9 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 postgres/init-vector.sh diff --git a/.env.example b/.env.example index ae55dc56..76959b8e 100644 --- a/.env.example +++ b/.env.example @@ -24,4 +24,4 @@ PGDATA="/var/lib/postgresql/data" OPDATA="/var/openproject/assets" COLLABORATIVE_SERVER_URL=ws://localhost:8080/hocuspocus COLLABORATIVE_SERVER_SECRET=secret12345 -POSTGRES_VERSION=17 # Note for existing setups: make sure this is the same version you are using right now, or upgrade your database +POSTGRES_VERSION=18 # Existing installations must follow the PostgreSQL 18 migration guide before upgrading diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..d867fc0f --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release notes + +## PostgreSQL 18 (OpenProject 18.0 rollout) + +- Default to `pgvector/pgvector:pg18-bookworm` and enable vector in newly initialized databases. +- Mount database storage at `/var/lib/postgresql`; PostgreSQL 18 stores the cluster in its `18/docker` subdirectory. +- Require an explicit database upgrade for existing installations. No automatic major upgrade runs. +- Keep the existing host-side `PGDATA` setting. Use new storage for the upgraded database. +- To stay on PostgreSQL 17, retain its image and previous mount with the override in the README. Setting `POSTGRES_VERSION=17` alone is insufficient. + +See the [migration guide](https://www.openproject.org/docs/installation-and-operations/misc/migration-to-postgresql18/) for backup, restore, activation, verification, and rollback. diff --git a/README.md b/README.md index f5a5354e..32a0a694 100644 --- a/README.md +++ b/README.md @@ -235,3 +235,23 @@ worker: dns: - "Your DNS IP" # OR add a public DNS resolver like 8.8.8.8 ``` + +## PostgreSQL 18 upgrade + +The database now defaults to `pgvector/pgvector:pg18-bookworm`. Fresh databases enable `vector` automatically. Existing databases require an explicit major-version upgrade; changing the image tag does not upgrade their data. + +Follow the [PostgreSQL 18 migration guide](https://www.openproject.org/docs/installation-and-operations/misc/migration-to-postgresql18/) before updating. Stop application writers before the final dump, restore into new storage, and retain the old database until verification succeeds. + +The host-side `PGDATA` setting still selects the persistent volume or directory. The container mount is now `/var/lib/postgresql`, with the cluster stored in `18/docker` below it. + +To retain an existing PostgreSQL 17 database, set `POSTGRES_VERSION=17` and add this `docker-compose.override.yml` (Compose 2.24.4 or newer): + +```yaml +services: + db: + image: postgres:17 + volumes: !override + - "${PGDATA:-pgdata}:/var/lib/postgresql/data" +``` + +This retains the previous image and storage layout. The version variable alone does not restore the old layout. To add pgvector to an existing PostgreSQL 17 installation, back up first, select `pgvector/pgvector:pg17-bookworm` in this override, check locale/collation compatibility, and activate the extension manually as described in the guide. diff --git a/docker-compose.yml b/docker-compose.yml index 5433221a..ac835579 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,17 +33,12 @@ x-op-app: &app services: db: - # The default here should really be 17 but is still 13 as to not break existing setups. - # New installations using the provided .env.example will use 17 to begin with. - # The default here will change to 17 as well with the next major update (18). - # - # Refer to the docs on how to upgrade to postgres 17 before then: - # https://www.openproject.org/docs/installation-and-operations/misc/migration-to-postgresql17/ - image: postgres:${POSTGRES_VERSION:-13} + image: pgvector/pgvector:pg${POSTGRES_VERSION:-18}-bookworm <<: *restart_policy stop_grace_period: "3s" volumes: - - "${PGDATA:-pgdata}:/var/lib/postgresql/data" + - "${PGDATA:-pgdata}:/var/lib/postgresql" + - "./postgres/init-vector.sh:/docker-entrypoint-initdb.d/vector.sh:ro" environment: POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-p4ssw0rd} POSTGRES_DB: openproject diff --git a/postgres/init-vector.sh b/postgres/init-vector.sh new file mode 100644 index 00000000..6e5ccdd8 --- /dev/null +++ b/postgres/init-vector.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) the OpenProject GmbH +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2013 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# See COPYRIGHT and LICENSE files for more details. +#++ + +set -euo pipefail + +psql --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" --set ON_ERROR_STOP=1 \ + --command 'CREATE EXTENSION IF NOT EXISTS vector;' From bf8ab0387ed1a2dfa8e37e524cadb2407bb8990e Mon Sep 17 00:00:00 2001 From: Cyril Rohr Date: Mon, 9 Nov 2026 15:36:46 +0100 Subject: [PATCH 2/2] Use SQL initialization and consolidate upgrade documentation --- CHANGELOG.md | 12 +++++------- README.md | 4 ++-- docker-compose.yml | 2 +- postgres/init-vector.sh | 33 --------------------------------- postgres/init-vector.sql | 28 ++++++++++++++++++++++++++++ 5 files changed, 36 insertions(+), 43 deletions(-) delete mode 100644 postgres/init-vector.sh create mode 100644 postgres/init-vector.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index d867fc0f..4eb8f627 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,9 @@ # Release notes -## PostgreSQL 18 (OpenProject 18.0 rollout) +## PostgreSQL 18 -- Default to `pgvector/pgvector:pg18-bookworm` and enable vector in newly initialized databases. -- Mount database storage at `/var/lib/postgresql`; PostgreSQL 18 stores the cluster in its `18/docker` subdirectory. -- Require an explicit database upgrade for existing installations. No automatic major upgrade runs. -- Keep the existing host-side `PGDATA` setting. Use new storage for the upgraded database. -- To stay on PostgreSQL 17, retain its image and previous mount with the override in the README. Setting `POSTGRES_VERSION=17` alone is insufficient. +New databases use `pgvector/pgvector:pg18-bookworm` and enable vector. The container storage mount changes to `/var/lib/postgresql`; the host-side `PGDATA` setting keeps its meaning. -See the [migration guide](https://www.openproject.org/docs/installation-and-operations/misc/migration-to-postgresql18/) for backup, restore, activation, verification, and rollback. +Existing databases require an explicit upgrade. To stay on PostgreSQL 17, use the [image and mount override](README.md#postgresql-18-upgrade). Setting `POSTGRES_VERSION=17` alone is insufficient. + +Follow the [migration guide](https://www.openproject.org/docs/installation-and-operations/misc/migration-to-postgresql18/) before upgrading. diff --git a/README.md b/README.md index 32a0a694..273a52d3 100644 --- a/README.md +++ b/README.md @@ -240,7 +240,7 @@ worker: The database now defaults to `pgvector/pgvector:pg18-bookworm`. Fresh databases enable `vector` automatically. Existing databases require an explicit major-version upgrade; changing the image tag does not upgrade their data. -Follow the [PostgreSQL 18 migration guide](https://www.openproject.org/docs/installation-and-operations/misc/migration-to-postgresql18/) before updating. Stop application writers before the final dump, restore into new storage, and retain the old database until verification succeeds. +Follow the [PostgreSQL 18 migration guide](https://www.openproject.org/docs/installation-and-operations/misc/migration-to-postgresql18/) before updating. The host-side `PGDATA` setting still selects the persistent volume or directory. The container mount is now `/var/lib/postgresql`, with the cluster stored in `18/docker` below it. @@ -254,4 +254,4 @@ services: - "${PGDATA:-pgdata}:/var/lib/postgresql/data" ``` -This retains the previous image and storage layout. The version variable alone does not restore the old layout. To add pgvector to an existing PostgreSQL 17 installation, back up first, select `pgvector/pgvector:pg17-bookworm` in this override, check locale/collation compatibility, and activate the extension manually as described in the guide. +This retains the previous image and storage layout. The version variable alone does not restore the old layout. See the migration guide for adding pgvector to an existing database. diff --git a/docker-compose.yml b/docker-compose.yml index ac835579..129f6301 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -38,7 +38,7 @@ services: stop_grace_period: "3s" volumes: - "${PGDATA:-pgdata}:/var/lib/postgresql" - - "./postgres/init-vector.sh:/docker-entrypoint-initdb.d/vector.sh:ro" + - "./postgres/init-vector.sql:/docker-entrypoint-initdb.d/vector.sql:ro" environment: POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-p4ssw0rd} POSTGRES_DB: openproject diff --git a/postgres/init-vector.sh b/postgres/init-vector.sh deleted file mode 100644 index 6e5ccdd8..00000000 --- a/postgres/init-vector.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -#-- copyright -# OpenProject is an open source project management software. -# Copyright (C) the OpenProject GmbH -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License version 3. -# -# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: -# Copyright (C) 2006-2013 Jean-Philippe Lang -# Copyright (C) 2010-2013 the ChiliProject Team -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# See COPYRIGHT and LICENSE files for more details. -#++ - -set -euo pipefail - -psql --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" --set ON_ERROR_STOP=1 \ - --command 'CREATE EXTENSION IF NOT EXISTS vector;' diff --git a/postgres/init-vector.sql b/postgres/init-vector.sql new file mode 100644 index 00000000..c4b40d75 --- /dev/null +++ b/postgres/init-vector.sql @@ -0,0 +1,28 @@ +---- copyright +-- OpenProject is an open source project management software. +-- Copyright (C) the OpenProject GmbH +-- +-- This program is free software; you can redistribute it and/or +-- modify it under the terms of the GNU General Public License version 3. +-- +-- OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +-- Copyright (C) 2006-2013 Jean-Philippe Lang +-- Copyright (C) 2010-2013 the ChiliProject Team +-- +-- This program is free software; you can redistribute it and/or +-- modify it under the terms of the GNU General Public License +-- as published by the Free Software Foundation; either version 2 +-- of the License, or (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- See COPYRIGHT and LICENSE files for more details. +--++ + +CREATE EXTENSION IF NOT EXISTS vector;