Skip to content

fix(pg): auto-migrate schema on pg serve startup#252

Merged
wesm merged 2 commits intowesm:mainfrom
tlmaloney:fix/pg-schema-migration-251
Mar 29, 2026
Merged

fix(pg): auto-migrate schema on pg serve startup#252
wesm merged 2 commits intowesm:mainfrom
tlmaloney:fix/pg-schema-migration-251

Conversation

@tlmaloney
Copy link
Copy Markdown
Contributor

Summary

  • Run EnsureSchema before CheckSchemaCompat in pg serve so missing tables (e.g. tool_result_events after upgrading from 0.16.x to 0.17.0) are created automatically
  • Read-only PG roles gracefully fall through to the existing compat check error
  • Add TestEnsureSchemaMigratesLegacySchema integration test that simulates a legacy schema upgrade

Closes #251

Test plan

  • make test passes
  • make test-postgres passes (exercises TestEnsureSchemaMigratesLegacySchema)
  • Manual: upgrade from 0.16.x schema, verify pg serve starts without manual SQL

🤖 Generated with Claude Code

Run EnsureSchema before CheckSchemaCompat in pg serve so that
missing tables (e.g. tool_result_events after upgrading from
0.16.x to 0.17.0) are created automatically. Read-only PG
roles gracefully fall through to the compat check.

Closes wesm#251

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@roborev-ci
Copy link
Copy Markdown

roborev-ci bot commented Mar 29, 2026

roborev: Combined Review (2709de4)

Verdict: One medium-severity startup reliability issue should be addressed before merge.

Medium

  • cmd/agentsview/pg.go:243: Unexpected EnsureSchema failures are currently downgraded to a warning and startup continues into CheckSchemaCompat. If migration fails after partial DDL, or on schema objects that CheckSchemaCompat does not verify, pg serve can start against a partially migrated schema and fail later in less obvious ways.
    • Suggested fix: Abort startup on any non-read-only EnsureSchema error, and keep warning-only handling limited to the explicitly accepted read-only case.

Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

Change EnsureSchema error handling from warning-and-continue to
fatal for non-read-only errors, preventing startup against a
partially migrated schema.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@roborev-ci
Copy link
Copy Markdown

roborev-ci bot commented Mar 29, 2026

roborev: Combined Review (93381ce)

Verdict: No medium-or-higher issues found; the change looks good to merge.

All reviewed agents agreed the diff is clean. The update to run a best-effort schema migration before compatibility checks, with read-only fallback behavior and added legacy-schema test coverage, did not surface any Medium, High, or Critical findings.


Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

@wesm wesm merged commit f54177d into wesm:main Mar 29, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pg serve fails after upgrade to 0.17.0: missing tool_result_events table

2 participants