fix: exclude external deps from orphan check in migration invariants (bd-ucgz)

External dependencies (external:<project>:<capability>) reference issues in
other projects and are expected to not exist in the local issues table.
The orphan check now excludes these with: AND d.depends_on_id NOT LIKE 'external:%'

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-23 12:41:54 -08:00
parent 77ff8283fe
commit f2db0a1d42

View File

@@ -148,11 +148,14 @@ func checkForeignKeys(db *sql.DB, snapshot *Snapshot) error {
}
// Check for orphaned dependencies (depends_on_id not in issues)
// Exclude external dependencies (external:<project>:<capability>) which reference
// issues in other projects and are expected to not exist locally
var orphanedDepsDependsOn int
err = db.QueryRow(`
SELECT COUNT(*)
FROM dependencies d
WHERE NOT EXISTS (SELECT 1 FROM issues WHERE id = d.depends_on_id)
AND d.depends_on_id NOT LIKE 'external:%'
`).Scan(&orphanedDepsDependsOn)
if err != nil {
return fmt.Errorf("failed to check orphaned dependencies (depends_on_id): %w", err)