- Add SourceType::Note with extract_note_document() and ParentMetadataCache - Migration 022: composite indexes for notes queries + author_id column - Migration 024: table rebuild adding 'note' to CHECK constraints, defense triggers - Migration 025: backfill existing non-system notes into dirty queue - Add lore notes CLI command with 17 filter options (author, path, resolution, etc.) - Support table/json/jsonl/csv output formats with field selection - Wire note dirty tracking through discussion and MR discussion ingestion - Fix test_migration_024_preserves_existing_data off-by-one (tested wrong migration) - Fix upsert_document_inner returning false for label/path-only changes
22 lines
1016 B
SQL
22 lines
1016 B
SQL
-- Migration 022: Composite query indexes for notes + author_id column
|
|
-- Optimizes author-scoped and project-scoped date-range queries on notes.
|
|
-- Adds discussion JOIN indexes and immutable author identity column.
|
|
|
|
-- Composite index for author-scoped queries (who command, notes --author)
|
|
CREATE INDEX IF NOT EXISTS idx_notes_user_created
|
|
ON notes(project_id, author_username COLLATE NOCASE, created_at DESC, id DESC)
|
|
WHERE is_system = 0;
|
|
|
|
-- Composite index for project-scoped date-range queries
|
|
CREATE INDEX IF NOT EXISTS idx_notes_project_created
|
|
ON notes(project_id, created_at DESC, id DESC)
|
|
WHERE is_system = 0;
|
|
|
|
-- Discussion JOIN indexes
|
|
CREATE INDEX IF NOT EXISTS idx_discussions_issue_id ON discussions(issue_id);
|
|
CREATE INDEX IF NOT EXISTS idx_discussions_mr_id ON discussions(merge_request_id);
|
|
|
|
-- Immutable author identity column (GitLab numeric user ID)
|
|
ALTER TABLE notes ADD COLUMN author_id INTEGER;
|
|
CREATE INDEX IF NOT EXISTS idx_notes_author_id ON notes(author_id) WHERE author_id IS NOT NULL;
|