make migrate-safe runs from the new release's image (#1045) #1062

Merged
claude-bot merged 2 commits from fix/1045-migrate-safe-new-release into main 2026-10-04 02:27:07 +00:00
Collaborator

Closes #1045. The owner's answer to Q146 (D274).

Summary

make migrate-safe ran its preflight, backup and migration with docker compose exec backend, which is the container that is running now: on an upgrade it checked and migrated with the old release's code. It now runs them from the release about to start, and touches no running service.

scripts/migrate-safe.sh (POSIX sh), called by the Makefile target:

  1. Fetch the new release. docker compose pull on an image host, docker compose build on a source build. Which one is asked of compose itself: whether the rendered config gives the migrate service a build: section.
  2. Preflight and backup in throwaway backend containers: the same user and ./backups mount as make backup-now, so the dump lands where that one writes, owned the same way.
  3. Migrate in a throwaway migrate container, run as that service's own command, so its backups-directory preparation and migrate credentials are used as they stand.

Every step is run --rm --no-deps, so db and redis are not touched. The script stops at the first failure and names the step.

Docs. docs/OPERATIONS.md (install, Updating Production, Running from Published Images, Safety rules), the comment by the migrate service, and the profile's prod-deploy line now recommend the command. #1044 had told image hosts not to use it.

Changelog

  • changelog.d/1045-migrate-safe-new-release.fixed.md

Test plan

Proved on docker-test in a throwaway compose project, with no published ports and a dummy .env; the dev stack was not touched.

  • Image host (COMPOSE_FILE with the images overlay, 4.5.0-rc2):
    • the three steps ran in three new run containers;
    • the dump appeared in ./backups;
    • the running backend kept the same container id and start time before and after.
  • Failure path: with db stopped, step 1 failed, the message named it, make exited non-zero, and nothing after it ran.
  • Source build: with the overlay removed, it built instead of pulling, then ran the same three steps.
  • Four unit tests of the build-or-pull detection. ruff clean; version sync and changelog checks OK.
  • Not seen: a real network pull of a newer tag on an image host. The image was already present locally, so pull had nothing to fetch.
  • Full suites: CI.

🤖 Generated with Claude Code

Closes #1045. The owner's answer to Q146 (D274). ## Summary `make migrate-safe` ran its preflight, backup and migration with `docker compose exec backend`, which is the container that is running now: on an upgrade it checked and migrated with the old release's code. It now runs them from the release about to start, and touches no running service. `scripts/migrate-safe.sh` (POSIX sh), called by the Makefile target: 1. **Fetch the new release.** `docker compose pull` on an image host, `docker compose build` on a source build. Which one is asked of compose itself: whether the rendered config gives the `migrate` service a `build:` section. 2. **Preflight and backup** in throwaway `backend` containers: the same user and `./backups` mount as `make backup-now`, so the dump lands where that one writes, owned the same way. 3. **Migrate** in a throwaway `migrate` container, run as that service's own command, so its backups-directory preparation and migrate credentials are used as they stand. Every step is `run --rm --no-deps`, so db and redis are not touched. The script stops at the first failure and names the step. **Docs.** `docs/OPERATIONS.md` (install, Updating Production, Running from Published Images, Safety rules), the comment by the `migrate` service, and the profile's prod-deploy line now recommend the command. #1044 had told image hosts not to use it. ## Changelog - [x] `changelog.d/1045-migrate-safe-new-release.fixed.md` ## Test plan Proved on docker-test in a throwaway compose project, with no published ports and a dummy `.env`; the dev stack was not touched. - [x] **Image host** (`COMPOSE_FILE` with the images overlay, `4.5.0-rc2`): - the three steps ran in three new `run` containers; - the dump appeared in `./backups`; - the running backend kept the same container id and start time before and after. - [x] **Failure path:** with db stopped, step 1 failed, the message named it, `make` exited non-zero, and nothing after it ran. - [x] **Source build:** with the overlay removed, it built instead of pulling, then ran the same three steps. - [x] Four unit tests of the build-or-pull detection. ruff clean; version sync and changelog checks OK. - [ ] **Not seen:** a real network pull of a newer tag on an image host. The image was already present locally, so pull had nothing to fetch. - [ ] Full suites: CI. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Format the migrate-safe detection test (#1045)
All checks were successful
CI / Backend lint (ruff) (pull_request) Successful in 50s
CI / Does this change touch the recording path? (pull_request) Successful in 33s
CI / Synthetic session harness (no GPU, no LLM) (pull_request) Has been skipped
CI / Summarisation accuracy eval harness (stub provider) (pull_request) Successful in 1m20s
CI / Bot/backend version sync (pull_request) Successful in 59s
CI / Feedback site tests (pull_request) Successful in 1m36s
CI / Bot tests and audit (pull_request) Successful in 2m19s
CI / Docker image build (pull_request) Successful in 3m57s
CI / Frontend (shard 2/2) (pull_request) Successful in 9m11s
CI / Frontend (shard 1/2) (pull_request) Successful in 10m46s
CI / End-to-end journeys (keyboard) (pull_request) Successful in 15m38s
CI / End-to-end journeys (desktop) (pull_request) Successful in 15m55s
CI / End-to-end journeys (phone) (pull_request) Successful in 11m46s
CI / Backend migration, tests, and audit (pull_request) Successful in 24m43s
89bfe2d11a
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
claude-bot deleted branch fix/1045-migrate-safe-new-release 2026-10-04 02:27:08 +00:00
rbrooks referenced this pull request from a commit 2026-10-04 06:57:14 +00:00
Sign in to join this conversation.
No description provided.