Repository navigation
fix(relay): migrate saved SQLite databases before accepting connections - #47
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_atandabort_reasoncolumns 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 EXISTScovers 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
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 COLUMNruns 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
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
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Final merge evidence:
.github/workflows/pr.ymlrun 46380435418, attempt 2, succeeded for exact head320e105605ef561771309098068594e8e8549b65, includingPR checks passed. A chat-fixture timing failure and a GitHub checkout DNS/network failure passed on retry. No check was bypassed. Merged asb07c02373db127587c3de2c0d34479965963e2af. The merged image workflow 46381822080 also passed its SQLite gate and published the immutable image.