mirror of
https://github.com/we-promise/sure.git
synced 2026-12-03 10:49:07 +08:00
## What Pins Postgres 18 everywhere a server version is specified, instead of a mix of floating `latest` and pinned 16 - and adds a boot-time guard so self-hosters with existing PG16 data get a clear, actionable error instead of a crash-looping database. | File | Before | After | |---|---|---| | `.github/workflows/ci.yml` (both test jobs) | `image: postgres` (untagged, floats on latest) | `image: postgres:18` | | `.github/workflows/llm-evals.yml` (both eval jobs) | `image: postgres:16` | `image: postgres:18` | | `.devcontainer/docker-compose.yml` | `image: postgres:16` | `image: postgres:18` + version guard | | `compose.example.yml` | `image: postgres:16` | `image: postgres:18` + version guard; backup sidecar `alpine:3.23` + `postgresql18-client~=18` | | `compose.example.ai.yml` (db service) | `image: pgvector/pgvector:pg16-trixie` | `image: pgvector/pgvector:pg18-trixie` + version guard | | `compose.example.ai.yml` (backup sidecar) | `alpine:3.20` + `postgresql16-client~=16` | `alpine:3.23` + `postgresql18-client~=18` | | `docs/hosting/ai.md` | recommends `pgvector/pgvector:pg16-trixie` | recommends `pgvector/pgvector:pg18-trixie` | ## Why Main CI floated on untagged `postgres`, which resolves to `latest` - PG18 today. Everything else pinned 16, so CI was effectively testing a different major version than the dev container and self-host examples shipped. Pinning 18 makes the repo deterministic and puts every surface on the version main CI has already been running green against. pgvector spots keep pgvector images (verified `pgvector/pgvector:pg18-trixie` exists on Docker Hub, as does `postgres:18`). The backup sidecars move to `alpine:3.23`, the first Alpine branch shipping `postgresql18-client` (18.4-r0 per pkgs.alpinelinux.org); pg_dump should match the server major. ## Migration guard (`bin/db-version-check.sh`) The stock postgres image dies with `FATAL: database files are incompatible with server` when the data dir is from an older major, and leaves users to figure out why. Each compose setup now runs a tiny one-shot `db-version-check` service (alpine, no new dependencies) that mounts the data volume read-only, reads `PG_VERSION`, and: - **fresh/empty data dir** -> passes, install proceeds at 18 - **data dir already at 18** -> passes - **data dir at any other major** -> exits 1 with an actionable message (migrate via `pg_upgrade` or dump/restore, see docs; or `docker volume rm` for a deliberately fresh start), and `depends_on: service_completed_successfully` stops the real `db` container from ever starting on the mismatched directory Wired into `compose.example.yml`, `compose.example.ai.yml` (the pgvector image uses the same `PG_VERSION` mechanism), and `.devcontainer/docker-compose.yml`. Not touched: the production `Dockerfile` and `.devcontainer/Dockerfile` (client tools only, no server), and the Helm chart (Postgres comes from the CloudNativePG operator's default image - separate decision). ## Caveat for self-hosters PG18 cannot read a PG16 data directory - upgrading requires `pg_upgrade` or dump/restore. The compose examples affect **fresh setups**; existing self-hosters on 16 keep working on 16 images and only move when they deliberately migrate. Dev-container users with existing `postgres-data` volumes should recreate the volume (`docker volume rm`) or migrate. The guard exists so that hitting this wall is obvious instead of cryptic. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Updates** * Updated PostgreSQL-based environments, CI workflows, and evaluation workflows to PostgreSQL 18. * Updated Pgvector and backup tooling for PostgreSQL 18 compatibility. * Updated hosting documentation and example configurations for the new PostgreSQL storage layout and migration options. * **Bug Fixes** * Added a database version check that prevents startup with incompatible existing data and provides actionable migration guidance. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>