Migrations run at server startup with no output, so admins can't tell
which migration is running, whether it waits on a lock, or how far it
got.
This adds a reporter to the migration driver. It logs:
- the pending migrations, and each step with its position and duration;
- the migration lock (debug level);
- a heartbeat every 10s during a lock wait or a long step, with the
connection state from `pg_stat_activity` and the blocking sessions.
The migration transaction is named `coder-migrate/<version>`, so other
instances and admins can see it. Heartbeat queries run on their own
connection and never delay the migration.
API: `Up(db, opts...)`, with `WithFS` (replaces `UpWithFS`) and
`WithLogger`. Without a logger, nothing is logged. Server startup turns
it on in #31790.
```
[info] database migration required from_version=1 target_version=3 pending=2
[info] applying database migration version=3 name=step_3 position=2 total=2
[info] still applying database migration elapsed_ms=1000 state=waiting_on_lock wait_event=relation blocked_by=[blocker] version=3 name=step_3 position=2 total=2
[info] database migration applied, pending commit version=3 name=step_3 position=2 total=2 duration_ms=1000
```
Tests compare log output with golden files in
`coderd/database/migrations/testdata/reporter`.
Closes ENT-235
_Written with Claude Code and Coder Agents, reviewed and tested by
@kirstaeff._
`make test-migrations` migrates from the current ref (the release
branch) to `origin/main`. When it fails, the hint told you every
migration in `main` must exist in the release branch, which is
backwards. The check actually requires that every migration in the
release branch also exists in `main` with the same number.
Swaps the version arguments so the hint describes the real requirement.
---
Generated by Coder Agents on behalf of @f0ssel.
- Update go.mod to use Go 1.24.1
- Update GitHub Actions setup-go action to use Go 1.24.1
- Fix linting issues with golangci-lint by:
- Updating to golangci-lint v1.57.1 (more compatible with Go 1.24.1)
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <claude@anthropic.com>