-- Migration 003: Performance and Orphan Detection Indexes -- Adds indexes for efficient orphan detection queries -- Index for orphan detection: find issues/discussions not seen recently -- Used by cleanup routines to identify potentially stale data CREATE INDEX IF NOT EXISTS idx_issues_last_seen ON issues(last_seen_at); CREATE INDEX IF NOT EXISTS idx_discussions_last_seen ON discussions(last_seen_at); CREATE INDEX IF NOT EXISTS idx_notes_last_seen ON notes(last_seen_at); -- Update schema version INSERT INTO schema_version (version, applied_at, description) VALUES (3, strftime('%s', 'now') * 1000, 'Performance and orphan detection indexes');