Skip to content

fix(relay): migrate saved SQLite databases before accepting connections - #47

Merged
karlorz merged 3 commits into
fork-mainfrom
codex/relay-sqlite-upgrade-columns
Nov 30, 2026
Merged

karlorz merged 3 commits into
fork-mainfrom
codex/relay-sqlite-upgrade-columns

Conversation

@karlorz

@karlorz karlorz commented Nov 30, 2026 •

Copy link
Copy Markdown
Owner

ELI5

After upgrading the self-hosted relay, a phone could still reach a directly connected server but could not reach its Mac through the relay. The relay had kept its saved database without adding two columns required by the upgraded code.

What Changed

Add the missing nullable roll_isolated_at and abort_reason columns through the existing SQLite upgrade path. A regression test reopens a real SQLite database with the older table shape, checks preserved admission state and assignment inventory reads, then reopens it again to verify that the migration is safe to repeat. Record restored-database validation in the fork preservation guide and inventory. Gate relay image publication on the migration regression, combined-host startup/trust checks, configuration checks, and relay typecheck in the active fork image workflow. Repair stale imports in the existing combined-host/configuration tests after upstream module moves.

Why

CREATE TABLE IF NOT EXISTS covers fresh databases but leaves existing tables unchanged. Reusing the established column migration mechanism repairs existing volumes while preserving accounts, devices, and pairings. Replacing the volume would discard user state.

Linked Issue

Maintainer repair of a production incident; no separate issue.

Visual Proof

N/A — server database migration. After the backed-up live schema repair, the relay regained a host control connection and the user confirmed the A35 could connect to the existing Mac entry.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below
  • Every added test fails without this change and avoids the test anti-patterns

Local tests/builds/installations are intentionally omitted at the user's explicit request after Mac resource exhaustion. The general Cloud Verify workflow is disabled in this fork. The active fork relay image workflow now runs the real SQLite migration regression, combined-host/configuration checks, and relay typecheck before building/publishing an image. The regression queries missing columns, so reverting the migration prevents it from passing; the new regression passed in GitHub CI. All 20 targeted relay tests, relay typecheck, and the image build passed after repairing stale imports in the existing tests.

Production repair validation on Linux: SQLite-aware backup; repair and real shipped assignment-inventory query against an isolated clone before live mutation; database integrity passed; device/invite rows unchanged; no further missing-column errors; relay host control restored; A35 connection confirmed by the user. The live data repair uses the same two nullable additions as this source change.

Performance

Two additional bounded schema introspection queries run when opening a SQLite database. Each ALTER TABLE ADD COLUMN runs once per existing database. No request-path work, polling, or PostgreSQL changes. The image workflow adds a single cloud dependency installation, focused test, and typecheck; publication waits for that check.

Risk

Level: Low. The change only adds nullable columns that current fresh SQLite schemas already contain. Existing databases and older clients retain their saved state. A code revert leaves these compatible columns in place; a private pre-repair backup is retained for recovery. Production rollback must account for writes after that backup.

AI Disclosure

Implemented with Codex.

Review

Reviewed the SQLite startup path, PostgreSQL equivalents, current schema, and the failing production query.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

No desktop/APK release or phone re-pairing is needed for this server repair. Mobile speech, SSH runtimes, and folder workspaces have no changed code.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Final merge evidence: .github/workflows/pr.yml run 46380435418, attempt 2, succeeded for exact head 320e105605ef561771309098068594e8e8549b65, including PR checks passed. A chat-fixture timing failure and a GitHub checkout DNS/network failure passed on retry. No check was bypassed. Merged as b07c02373db127587c3de2c0d34479965963e2af. The merged image workflow 46381822080 also passed its SQLite gate and published the immutable image.

@karlorz
karlorz merged commit b07c023 into fork-main Nov 30, 2026
96 of 100 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.

1 participant