fix(storage): add batch ID conflict detection and fix schema indexes

- Add checkForExistingIDs function to detect duplicate IDs within batch
  and conflicts with existing database entries before insert
- Remove thread_id index creation from schema.go since thread_id column
  is added by migration 020_edge_consolidation.go

🤖 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-18 19:11:50 -08:00
parent 2ea1b74f43
commit 9dc34da64a
2 changed files with 60 additions and 2 deletions

View File

@@ -59,8 +59,9 @@ CREATE INDEX IF NOT EXISTS idx_dependencies_issue ON dependencies(issue_id);
CREATE INDEX IF NOT EXISTS idx_dependencies_depends_on ON dependencies(depends_on_id);
CREATE INDEX IF NOT EXISTS idx_dependencies_depends_on_type ON dependencies(depends_on_id, type);
CREATE INDEX IF NOT EXISTS idx_dependencies_depends_on_type_issue ON dependencies(depends_on_id, type, issue_id);
CREATE INDEX IF NOT EXISTS idx_dependencies_thread ON dependencies(thread_id) WHERE thread_id != '';
CREATE INDEX IF NOT EXISTS idx_dependencies_thread_type ON dependencies(thread_id, type) WHERE thread_id != '';
-- NOTE: idx_dependencies_thread and idx_dependencies_thread_type are created by
-- migration 020_edge_consolidation.go after adding the thread_id column.
-- They cannot be in the schema because existing databases may not have thread_id yet.
-- Labels table
CREATE TABLE IF NOT EXISTS labels (