CodeIssuesPull RequestsActionsSecurityInsights
✨ AI
More
Settings

fix(import): repair the bulk import that cloned 38 repos but created zero DB rows #3527

Merged⚡ AI-generatedXSccantynz wants to mergefix/import-onconflict-partial-indexmainopened 25d ago
ccantynzcommented 25d ago

The first real bulk run against ccantynz-alt cloned every repo to disk and created zero DB rows. Three fixes in importOneRepo:

  1. ON CONFLICT vs partial index. repos_owner_name is partial (WHERE org_id IS NULL, migration 0004). ON CONFLICT (owner_id, name) without the predicate makes Postgres reject the whole insert — "no unique or exclusion constraint matching the ON CONFLICT specification" — and it threw after the clone landed. Now passes where: org_id is null.

  2. Orphan adoption. Destination dir present with commits but no DB row = a prior run died after the clone. Adopt it (insert the row, skip the re-download) instead of dying on "destination path already exists". Empty leftovers are removed and re-cloned.

  3. Case-insensitive existing check. Pre-import repos stored with original casing (ccantynz/Vapron) were invisible to the exact-match check, so run 1 cloned a duplicate vapron.git beside Vapron.git. Now compares lower(name).

bun test import suites 11/11, tsc clean.

🤖 Generated with Claude Code

ccantynzAI Reviewcommented 25d ago

AI Triage

(no summary)

Priority: medium Risk area: mixed

Suggested labels: (no label suggestions) Suggested reviewers: (no reviewer suggestions)

Suggestions only — nothing has been applied. The PR author stays in control.

Cross-repo impact

See what breaks downstream if this PR merges.

Analyze →
⮌ Merged

This pull request was merged into main.

c comment · e edit title · m merge · a approve · r request changes · ? shortcuts