feat: Handle FOREIGN KEY constraint violations gracefully during import (bd-koab)
When importing JSONL after merges that include deletions, FK constraint violations can occur if an issue references a deleted issue. Previously, import would fail completely. Now it continues and reports skipped dependencies. Changes: - Add SkippedDependencies field to Result/ImportResult structs - Update importDependencies() to detect FK violations using IsForeignKeyConstraintError() - Log warnings for each skipped dependency with issue IDs and type - Continue importing remaining dependencies instead of failing - Display summary of all skipped dependencies at end of import Example output: Warning: Skipping dependency due to missing reference: bd-b → bd-a (blocks) ⚠️ Warning: Skipped 2 dependencies due to missing references: - bd-b → bd-a (blocks) - bd-c → bd-a (parent-child) This can happen after merges that delete issues referenced by other issues. The import continued successfully - you may want to review the skipped dependencies. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -366,6 +366,16 @@ NOTE: Import requires direct database access and does not work with daemon mode.
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "\n")
|
||||
|
||||
// Print skipped dependencies summary if any
|
||||
if len(result.SkippedDependencies) > 0 {
|
||||
fmt.Fprintf(os.Stderr, "\n⚠️ Warning: Skipped %d dependencies due to missing references:\n", len(result.SkippedDependencies))
|
||||
for _, dep := range result.SkippedDependencies {
|
||||
fmt.Fprintf(os.Stderr, " - %s\n", dep)
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "\nThis can happen after merges that delete issues referenced by other issues.\n")
|
||||
fmt.Fprintf(os.Stderr, "The import continued successfully - you may want to review the skipped dependencies.\n")
|
||||
}
|
||||
|
||||
// Print force message if metadata was updated despite no changes
|
||||
if force && result.Created == 0 && result.Updated == 0 && len(result.IDMapping) == 0 {
|
||||
fmt.Fprintf(os.Stderr, "Metadata updated (database already in sync with JSONL)\n")
|
||||
|
||||
Reference in New Issue
Block a user