fix(db): rename four more repo-identity tables and guard the list against drift - #9843
Conversation
…inst drift `renameRepositoryIdentity` walks every repo-identity table to move a renamed repo's rows forward, but four tables carrying a repo-identity column were never walked: `linked_issue_claims`, `bounty_lifecycle_events`, `webhook_events`, and `score_previews`. A rename orphaned their rows under the old name. Add an explicit per-table block for each (matching the module's convention): `linked_issue_claims` (PK repo_full_name/pull_number/issue_number) folds a stray new-name row first, keeping the pre-existing old-name row's claimed_at, exactly as pullRequests/issues do; the other three have surrogate primary keys with no unique constraint on the repo column, so each is a plain UPDATE with no fold. Export `RENAME_OUT_OF_SCOPE_TABLES` (the eight deliberately-excluded tables the prose block already documents) and add a completeness drift guard: every schema.ts table with a repo_full_name/repository_full_name column must be renamed here or be exempt, no table may be both, and no exempt entry may be dead — the list had drifted three times before. Mirrors retention.test.ts's RETENTION_POLICY guard. Closes JSONbored#9650
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
|
Warning ⏸️ LoopOver review result - manual review recommendedReview updated: 2026-07-29 13:59:34 UTC
Review summary Nits — 1 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. Decision record
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9843 +/- ##
==========================================
+ Coverage 79.04% 79.10% +0.05%
==========================================
Files 281 282 +1
Lines 58409 58576 +167
Branches 6698 6721 +23
==========================================
+ Hits 46171 46337 +166
Misses 11955 11955
- Partials 283 284 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
…inst drift (#9843) `renameRepositoryIdentity` walks every repo-identity table to move a renamed repo's rows forward, but four tables carrying a repo-identity column were never walked: `linked_issue_claims`, `bounty_lifecycle_events`, `webhook_events`, and `score_previews`. A rename orphaned their rows under the old name. Add an explicit per-table block for each (matching the module's convention): `linked_issue_claims` (PK repo_full_name/pull_number/issue_number) folds a stray new-name row first, keeping the pre-existing old-name row's claimed_at, exactly as pullRequests/issues do; the other three have surrogate primary keys with no unique constraint on the repo column, so each is a plain UPDATE with no fold. Export `RENAME_OUT_OF_SCOPE_TABLES` (the eight deliberately-excluded tables the prose block already documents) and add a completeness drift guard: every schema.ts table with a repo_full_name/repository_full_name column must be renamed here or be exempt, no table may be both, and no exempt entry may be dead — the list had drifted three times before. Mirrors retention.test.ts's RETENTION_POLICY guard. Closes #9650
What & why
renameRepositoryIdentity(src/db/repo-identity-rename.ts) walks every repo-identity table to move a renamed repo's rows forward, but four tables carrying a repo-identity column were never walked:linked_issue_claims,bounty_lifecycle_events,webhook_events, andscore_previews. A repo rename orphaned their rows under the old name. Nothing guarded the list, so it has drifted three times.The fix
linked_issue_claims(PKrepo_full_name, pull_number, issue_number) — fold a stray new-name row on the composite key first, keeping the pre-existing old-name row'sclaimed_at, exactly aspullRequests/issuesdo; history is never dropped for the new-name row.bounty_lifecycle_events,webhook_events,score_previews— surrogateid/delivery_idprimary keys with no unique constraint on the repo column, so each is a plainUPDATE … SET <col> = new WHERE <col> = old, matching theorb_webhook_eventsblock.RENAME_OUT_OF_SCOPE_TABLES— the eight deliberately-excluded tables the module's prose block already documents (rebuildable caches, orphanedreview_targets,repo_chunks, …).describe("renameRepositoryIdentity completeness (drift guard)")): everyschema.tstable with arepo_full_name/repository_full_namecolumn must be either renamed here or exempt; no table may be both; no exempt entry may be dead. Mirrorsretention.test.ts'sRETENTION_POLICYcompleteness guard, using drizzle-orm'sgetTableColumns/getTableNameoverimport * as schema.Tests (
test/unit/repo-identity-rename.test.ts)linked_issue_claims: a colliding new-name row is folded and the OLD-name row'sclaimed_atsurvives (fails onmain).bounty_lifecycle_events/webhook_events/score_previews: rows seeded under the old name leave zero rows under it after the rename (fail onmain).Validation
npm run typecheckgreen;npm run db:schema-drift:checkgreen (no schema change); the suite (82 tests) green.linked_issue_claimscollision branch).git diff --check <base> HEADclean; no migration change.Closes #9650