From 7595d150a7548b0a068913bf27d7f890586c187a Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sun, 4 Oct 2026 16:52:44 +0200 Subject: [PATCH] fix(web-app-mobilizon): patch four migrations for PostgreSQL 18 Every fresh Mobilizon deploy on PostgreSQL 18 died in migration 20190806131306. Four migrations drop the integer id column, add a uuid id without NOT NULL and declare it the primary key in the same ALTER TABLE. PostgreSQL 18 rejects that with 42P16 "primary key column "id" is not marked NOT NULL", PostgreSQL 17 accepted it. The container exited 1 and restarted in a loop, in compose and in swarm. Upstream fixed it for 5.3.0 by adding null: false to that line in the four migrations. No published image carries the fix yet, so the role builds its own image on top of the pinned upstream one and applies the same one-line change to the same four files. The build fails once a base image no longer contains the unfixed line and names the migration, so the patch cannot outlive its reason unnoticed. TODO.md lists what to delete then. Closes #779 Co-Authored-By: Claude Opus 5.5 (1M context) --- roles/web-app-mobilizon/TODO.md | 3 +++ roles/web-app-mobilizon/files/Dockerfile | 18 ++++++++++++++++++ roles/web-app-mobilizon/meta/services.yml | 1 + .../web-app-mobilizon/templates/compose.yml.j2 | 4 ++++ roles/web-app-mobilizon/vars/main.yml | 2 ++ 5 files changed, 28 insertions(+) create mode 100644 roles/web-app-mobilizon/TODO.md create mode 100644 roles/web-app-mobilizon/files/Dockerfile diff --git a/roles/web-app-mobilizon/TODO.md b/roles/web-app-mobilizon/TODO.md new file mode 100644 index 0000000000..123fe6e004 --- /dev/null +++ b/roles/web-app-mobilizon/TODO.md @@ -0,0 +1,3 @@ +# TODO + +- Drop the custom image build once the pinned Mobilizon release ships the PostgreSQL 18 migration fix (upstream merge request 1683, milestone 5.3.0). The build of `files/Dockerfile` fails on that release and names the migration that no longer needs the patch. Then delete `files/Dockerfile`, the `build` block in `templates/compose.yml.j2`, `MOBILIZON_IMAGE` and `MOBILIZON_VERSION` in `vars/main.yml`, and `custom: true` in `meta/services.yml`. diff --git a/roles/web-app-mobilizon/files/Dockerfile b/roles/web-app-mobilizon/files/Dockerfile new file mode 100644 index 0000000000..165a86a54b --- /dev/null +++ b/roles/web-app-mobilizon/files/Dockerfile @@ -0,0 +1,18 @@ +ARG MOBILIZON_IMAGE +ARG MOBILIZON_VERSION +FROM ${MOBILIZON_IMAGE}:${MOBILIZON_VERSION} + +RUN set -eu; \ + cd /lib/mobilizon-*/priv/repo/migrations; \ + for migration in \ + 20190806131306_add_url_to_follows_and_move_to_uuid.exs \ + 20190813160207_add_url_and_uuid_to_participants.exs \ + 20200218170232_move_member_id_to_uuid.exs \ + 20200721131521_add_url_to_conversation.exs; \ + do \ + if ! grep -q 'add(:id, :uuid, primary_key: true)$' "${migration}"; then \ + echo "${migration} no longer contains 'add(:id, :uuid, primary_key: true)': the base image ships the PostgreSQL 18 migration fix (framagit.org/kaihuri/mobilizon merge request 1683). Drop this Dockerfile and the custom build of web-app-mobilizon." >&2; \ + exit 1; \ + fi; \ + sed -i 's/add(:id, :uuid, primary_key: true)$/add(:id, :uuid, primary_key: true, null: false)/' "${migration}"; \ + done diff --git a/roles/web-app-mobilizon/meta/services.yml b/roles/web-app-mobilizon/meta/services.yml index 02e75b269c..14491f93d0 100644 --- a/roles/web-app-mobilizon/meta/services.yml +++ b/roles/web-app-mobilizon/meta/services.yml @@ -40,6 +40,7 @@ mobilizon: image: docker.io/kaihuri/mobilizon name: mobilizon version: 5.2.4 + custom: true min_storage: 825MB titel: Mobilizon on {{ DOMAIN_PRIMARY | upper }} ports: diff --git a/roles/web-app-mobilizon/templates/compose.yml.j2 b/roles/web-app-mobilizon/templates/compose.yml.j2 index e1d93b4ab2..28d8819bc7 100644 --- a/roles/web-app-mobilizon/templates/compose.yml.j2 +++ b/roles/web-app-mobilizon/templates/compose.yml.j2 @@ -1,6 +1,10 @@ {% include 'roles/sys-svc-compose/templates/base.yml.j2' %} {% set service_name = 'mobilizon' %} {{ service_name }}: + {{ lookup('template', 'roles/sys-svc-container/templates/build.yml.j2') | indent(4) }} + args: + MOBILIZON_IMAGE: "{{ MOBILIZON_IMAGE }}" + MOBILIZON_VERSION: "{{ MOBILIZON_VERSION }}" {{ lookup('container_image', application_id, 'mobilizon') }} {{ lookup('compose_only', 'container_name', mobilizon_container) }} {{ lookup('container_volumes', service_name) | indent(4) }} diff --git a/roles/web-app-mobilizon/vars/main.yml b/roles/web-app-mobilizon/vars/main.yml index 6dd288e199..81bc2753b2 100644 --- a/roles/web-app-mobilizon/vars/main.yml +++ b/roles/web-app-mobilizon/vars/main.yml @@ -4,4 +4,6 @@ container_port: "{{ lookup('config', application_id, 'services.mobilizon.ports.i mobilizon_host_conf_exs_file: "{{ [ lookup('container', application_id, 'directories.config'), 'config.exs' ] | path_join }}" mobilizon_container: "{{ lookup('config', application_id, 'services.mobilizon.name') }}" +MOBILIZON_IMAGE: "{{ lookup('config', application_id, 'services.mobilizon.image') }}" +MOBILIZON_VERSION: "{{ lookup('config', application_id, 'services.mobilizon.version') }}" MOBILIZON_OIDC_ENABLED: "{{ lookup('config', application_id, 'services.sso.enabled') }}"