mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 04:50:59 +00:00
feat(db): move the bundled database to Postgres 18
The compose file runs Postgres 18. An install from v1.45 or earlier keeps its Postgres 16 data in `pgdata`, which 18 cannot open, so a one-shot `db-upgrade` service moves it on the first start: it starts Postgres 16 on the old volume inside its own container, streams a dump into 18 in one transaction, compares every table's row count, gathers planner statistics and marks the old volume as moved. The app waits for it to succeed. The old volume is never changed apart from the marker, so the way back is the previous image and volume lines. A move cut short leaves a "moving" marker and runs again from scratch; an emptied new volume after a finished move is refused rather than refilled with the old state. scripts/compose-db-upgrade-check.sh plays all of it against real containers from the v1.45.0 compose file, and runs in CI on every change to the compose file. Pull requests run the integration suite and e2e on Postgres 18; the nightly integration run keeps 16 covered for installs that bring their own database.
This commit is contained in:
1 parent
6b3c1cc433
commit
d4d91994e8
11 files changed
+445
-24
No files matched your search
@@ -0,0 +1,51 @@
|
||||
name: Compose database move
|
||||
|
||||
# Plays the Postgres 16 -> 18 move in docker-compose.yml against real
|
||||
# containers: a v1.45 database with every migration applied, then the current
|
||||
# compose file's `db-upgrade` on its first start, a second start, a move cut
|
||||
# short, an emptied new volume and a new install. The service runs once on an
|
||||
# operator's host and has no second chance there, so every change to the
|
||||
# compose file or to the check runs it here first.
|
||||
# `scripts/compose-db-upgrade-check.sh` is the same check, runnable locally.
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
paths:
|
||||
- docker-compose.yml
|
||||
- scripts/compose-db-upgrade-check.sh
|
||||
- .github/workflows/compose-db-upgrade.yml
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- docker-compose.yml
|
||||
- scripts/compose-db-upgrade-check.sh
|
||||
- .github/workflows/compose-db-upgrade.yml
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
move:
|
||||
name: Postgres 16 -> 18 move
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
# The check reads the v1.45 compose file from its tag.
|
||||
- name: Fetch the v1.45.0 tag
|
||||
run: git fetch --no-tags --depth=1 origin tag v1.45.0
|
||||
|
||||
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
|
||||
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: 22
|
||||
cache: pnpm
|
||||
|
||||
- run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Move check
|
||||
run: bash scripts/compose-db-upgrade-check.sh
|
||||
@@ -40,7 +40,7 @@ jobs:
|
||||
name: e2e shard ${{ matrix.shard }}/3
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
image: postgres:18-alpine
|
||||
env:
|
||||
POSTGRES_USER: healthlog
|
||||
POSTGRES_PASSWORD: healthlog
|
||||
@@ -158,7 +158,7 @@ jobs:
|
||||
image: mcr.microsoft.com/playwright:v${{ needs.playwright-version.outputs.version }}-noble
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
image: postgres:18-alpine
|
||||
env:
|
||||
POSTGRES_USER: healthlog
|
||||
POSTGRES_PASSWORD: healthlog
|
||||
|
||||
@@ -56,7 +56,7 @@ jobs:
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
image: postgres:18-alpine
|
||||
env:
|
||||
POSTGRES_USER: healthlog
|
||||
POSTGRES_PASSWORD: healthlog
|
||||
|
||||
@@ -84,7 +84,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
shard: [1, 2, 3, 4]
|
||||
name: integration shard ${{ matrix.shard }}/4 (shuffled)
|
||||
name: integration shard ${{ matrix.shard }}/4 (shuffled, Postgres 16)
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
@@ -110,6 +110,10 @@ jobs:
|
||||
shell: bash
|
||||
env:
|
||||
HEALTHLOG_INTEGRATION_WORKERS: "3"
|
||||
# Pull requests run the suite on Postgres 18, the compose default.
|
||||
# Installs that bring their own database may still be on 16, so the
|
||||
# nightly run keeps that major covered without doubling every PR.
|
||||
INTEGRATION_PG_IMAGE: "postgres:16-alpine"
|
||||
# Four times each property's own case count; a property's timeout
|
||||
# grows by the same factor (`propertyTimeout`).
|
||||
FC_RUNS_FACTOR: "4"
|
||||
|
||||
Reference in new issue
Block a user