fix(server): drop V1 projections nothing reads after the V2 upgrade#20947

merged1
main
t3/v1-cleanup-1-drop-tables
opened13d agobyJJulius Marminge
View on GitHubTwo-way sync enabledPR last imported 9d ago

Upgrading to 0.1.0 starts statev2.sqlite as a full copy of the V1 database. V2 never reads six of those V1 tables, so long-time users keep them forever: 5.9 GiB in #20922, mostly the old activity log.

Migration 63 drops projection_thread_activities, projection_turns, projection_thread_proposed_plans, projection_pending_approvals, projection_state and checkpoint_diff_blobs. Nothing on main or in 0.1.0 reads them outside migrations and tests. The V1 transcript import still reads threads, messages and pull request links, so those tables stay. Builds before 0.1.0 read state.sqlite, never this file, so rolling back is unaffected.

Dropping only frees pages, which is quick: 696 MiB dropped in 168 ms. Upgraded databases have auto_vacuum off, so those pages count as reclaimable space. The Settings notice from #19437 suggests t3 doctor at 1 GiB, and its existing "Reclaim database space" repair returns them to disk.

The mobile showcase seed still wrote into these tables and waited for them to exist. Those rows were never shown by V2 clients (#15013), so the seed no longer writes them.

Verification

Migration test: the six tables are gone, while the transcript import tables and their rows are kept. The V1 cutover integration test and the showcase test still pass.

On a copy of a real 8.58 GiB V2 database, a normal server start ran migration 63:

1before: Database: 8.58 GiB, 0 KiB reclaimable.
2after: Database: 8.58 GiB, 694.9 MiB reclaimable.

Part of #20922. #20948 adds the opt-in repair for the V1 file itself.

šŸ¤– Generated with Claude Code

Closes #20922

Checks

24 successful Ā· 11 skipped Ā· 1 neutral
All checks passed
e910922

Added 1 commit

  • fix(server): drop V1 projections nothing reads after the V2 upgradee910922
Synced from GitHub

Approvability

Verdict: Needs Human Approval

Macroscope's review found this PR requires human approval — The upgrade now automatically deletes six existing SQLite tables and their stored rows, while the other changes update tests and a development showcase seed. Although the migration is tested and intended tables are obsolete, its irreversible production data/schema impact warrants deliberate review.

You can add or adjust custom eligibility rules. Learn more.

Synced from GitHub

Thread transfer impact

āœ… Thread transfer remains within every enforced ceiling.

ProviderMetricMain baselineThis PRImpactPR ceiling
CodexTotal thread wire5.0 KiB5.0 KiB+7 B (+0.1%)6.8 KiBāœ…
CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiBāœ…
CodexLive turn WebSocket wire1.2 KiB1.2 KiB+7 B (+0.6%)2.0 KiBāœ…
CodexLive turn WebSocket decoded20.9 KiB20.9 KiB0 B (0.0%)29.3 KiBāœ…
CodexLive turn messages220 (0.0%)8āœ…
ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiBāœ…
ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiBāœ…
ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiBāœ…
ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB0 B (0.0%)29.3 KiBāœ…
ClaudeLive turn messages220 (0.0%)8āœ…

Baseline: 4b1024d Ā· PR result: e910922 Ā· Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

Synced from GitHub

Review in Change Stack →

No actionable comments were generated in the recent review. šŸŽ‰

ā„¹ļø Recent review info
āš™ļø Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Team
  • Run ID: d1846242-2877-452b-85b2-d58427508d24
šŸ“„ Commits

Reviewing files that changed from the base of the PR and between 4b1024dafe4766ea7c59546936c21ce0fab8acb3 and e910922a9be903434eb759a50bbece9e5129f102.

šŸ“’ Files selected for processing: 6
  • apps/server/src/persistence/Migrations.ts
  • apps/server/src/persistence/Migrations/055_OrchestrationV2.test.ts
  • apps/server/src/persistence/Migrations/063_DropUnusedV1Projections.test.ts
  • apps/server/src/persistence/Migrations/063_DropUnusedV1Projections.ts
  • apps/server/src/persistence/reconcileV2PreviewMigration.test.ts
  • scripts/mobile-showcase-environment.ts
šŸ’¤ Files with no reviewable changes: 1
  • scripts/mobile-showcase-environment.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

šŸ“ Walkthrough

Migration 63 drops six projection tables and is added to migration registration and upgrade expectations. Migration tests check that transcript tables and message data remain. The mobile showcase seed no longer creates or clears the removed projection data.

Changes: V1 Projection Cleanup

Layer / File(s)Summary
Register and verify migration 63
apps/server/src/persistence/Migrations/063_DropUnusedV1Projections.ts, apps/server/src/persistence/Migrations.ts, apps/server/src/persistence/Migrations/063_DropUnusedV1Projections.test.ts, apps/server/src/persistence/Migrations/055_OrchestrationV2.test.ts, apps/server/src/persistence/reconcileV2PreviewMigration.test.ts
Migration 63 drops six tables if they exist. Registration and upgrade expectations include the migration. Its test checks that three transcript-related tables and an inserted message remain.
Update mobile showcase seeding
scripts/mobile-showcase-environment.ts
The seed no longer inserts projection turns, activity records, or projection-state rows. Its cleanup list now includes only thread messages, thread sessions, and threads.

Priority: āž– Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Suggested reviewers: realhasanshoaib, maria-rcks

Merge Risk: ⚪ Minimal · up to e9109

The change drops unused V1 tables so upgraded databases can reclaim space. No remaining code path reads those tables, and the transcript import tables are kept. No merge-blocking risk was found.

Pre-merge checks: Passed 4
Check nameStatusExplanation
Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
Title checkPassedThe title clearly and concisely describes the main change: removing unused V1 projections after the V2 upgrade.
Description checkPassedThe description explains the problem, the migration changes, retained tables, scope, issue references, rollback impact, and focused verification results. It is sufficiently complete despite not using …
Full details: Description check

Explanation

The description explains the problem, the migration changes, retained tables, scope, issue references, rollback impact, and focused verification results. It is sufficiently complete despite not using all template headings explicitly.

✨ Finishing Touches
šŸ“ Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix Ā· Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.