Fix collision resolver: sync ID counters before remapping
The collision resolver was failing when remapping issues to new IDs because the issue_counters table was out of sync with actual database IDs. Test issues (bd-200 through bd-312) were created without updating the counter, causing UNIQUE constraint violations when --resolve-collisions tried to use those IDs. Added SyncAllCounters() call before remapping to ensure counters reflect all existing issues in the database. This prevents ID collisions during import. Fixes the core functionality needed for multi-device git-based sync (bd-271). Amp-Thread-ID: https://ampcode.com/threads/T-a2a94e1b-b220-41b0-bf7d-f2640a44292b Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -244,6 +244,11 @@ func countReferences(issueID string, allIssues []*types.Issue, allDeps map[strin
|
||||
func RemapCollisions(ctx context.Context, s *SQLiteStorage, collisions []*CollisionDetail, allIssues []*types.Issue) (map[string]string, error) {
|
||||
idMapping := make(map[string]string)
|
||||
|
||||
// Sync counters before remapping to avoid ID collisions
|
||||
if err := s.SyncAllCounters(ctx); err != nil {
|
||||
return nil, fmt.Errorf("failed to sync ID counters: %w", err)
|
||||
}
|
||||
|
||||
// For each collision (in order of ascending reference score)
|
||||
for _, collision := range collisions {
|
||||
oldID := collision.ID
|
||||
|
||||
Reference in New Issue
Block a user