wulf-pulse/migrations/002_add_indexes.sql
root 6eee14f8af Add comprehensive admin features and multi-system integration
- Add admin dashboard with sync controls and data browser
- Implement RMM, Auvik, and Addigy organization mappings
- Add chunked ticket sync with progress tracking
- Implement entity sync service with rate limiting
- Add analytics engine and performance optimizer
- Create data browser for all PSA entities
- Add navigation components and UI improvements
- Implement background processing and sync services
- Add comprehensive documentation and migration scripts
- Update configuration items with multi-system support
- Enhance contact management and purchase history
- Add issue type assignment and LLM analyzer
- Improve error handling and logging utilities
2025-11-19 14:18:16 -05:00

28 lines
2.1 KiB
SQL

-- Additional Indexes for Performance Optimization
-- This migration adds additional indexes beyond those in the initial schema
-- Note: Basic indexes were already created in 001_initial_schema.sql
-- This file is for any additional performance indexes discovered during development
-- Composite indexes for common query patterns
CREATE INDEX IF NOT EXISTS idx_tickets_company_status ON tickets(company_id, status) WHERE is_deleted = false;
CREATE INDEX IF NOT EXISTS idx_tickets_assigned_date ON tickets(assigned_resource_id, create_date DESC) WHERE is_deleted = false;
CREATE INDEX IF NOT EXISTS idx_tasks_project_status ON tasks(project_id, status) WHERE is_deleted = false;
CREATE INDEX IF NOT EXISTS idx_config_items_company_active ON configuration_items(company_id, is_active) WHERE is_deleted = false;
-- Full-text search indexes (if needed in future)
-- CREATE INDEX IF NOT EXISTS idx_tickets_title_fts ON tickets USING gin(to_tsvector('english', title));
-- CREATE INDEX IF NOT EXISTS idx_tickets_description_fts ON tickets USING gin(to_tsvector('english', description));
-- Partial indexes for active records only (more efficient)
CREATE INDEX IF NOT EXISTS idx_companies_active_only ON companies(id) WHERE is_active = true AND is_deleted = false;
CREATE INDEX IF NOT EXISTS idx_resources_active_only ON resources(id) WHERE is_active = true AND is_deleted = false;
CREATE INDEX IF NOT EXISTS idx_contacts_active_only ON contacts(company_id) WHERE is_active = true AND is_deleted = false;
-- Indexes for sync operations
CREATE INDEX IF NOT EXISTS idx_companies_last_modified ON companies(last_tracked_modification_date_time DESC) WHERE is_deleted = false;
CREATE INDEX IF NOT EXISTS idx_tickets_last_activity ON tickets(last_activity_date DESC) WHERE is_deleted = false;
CREATE INDEX IF NOT EXISTS idx_contacts_last_modified ON contacts(last_modified_date DESC) WHERE is_deleted = false;
COMMENT ON INDEX idx_tickets_company_status IS 'Optimizes queries filtering tickets by company and status';
COMMENT ON INDEX idx_config_items_company_active IS 'Optimizes queries for active config items by company';