24 lines
1.1 KiB
MySQL
24 lines
1.1 KiB
MySQL
|
|
-- Migration: Add additional indexes for improved query performance
|
||
|
|
-- Version: 014
|
||
|
|
|
||
|
|
-- Index for audit log queries by user and date (activity reports)
|
||
|
|
CREATE INDEX IF NOT EXISTS idx_audit_log_user_created ON audit_log(user_id, created_at DESC);
|
||
|
|
|
||
|
|
-- Index for audit log queries by action type (security monitoring)
|
||
|
|
CREATE INDEX IF NOT EXISTS idx_audit_log_action_type ON audit_log(action_type, created_at DESC);
|
||
|
|
|
||
|
|
-- Index for tickets by status only (status filtering)
|
||
|
|
CREATE INDEX IF NOT EXISTS idx_tickets_status ON tickets(status);
|
||
|
|
|
||
|
|
-- Composite index for common dashboard queries (status + priority + created_at)
|
||
|
|
CREATE INDEX IF NOT EXISTS idx_tickets_status_priority_created ON tickets(status, priority, created_at DESC);
|
||
|
|
|
||
|
|
-- Index for ticket comments by ticket_id and date (comment listing)
|
||
|
|
CREATE INDEX IF NOT EXISTS idx_comments_ticket_created ON ticket_comments(ticket_id, created_at DESC);
|
||
|
|
|
||
|
|
-- Index for API keys by key value (authentication lookups)
|
||
|
|
CREATE INDEX IF NOT EXISTS idx_api_keys_key_value ON api_keys(key_value);
|
||
|
|
|
||
|
|
-- Index for user preferences lookup
|
||
|
|
CREATE INDEX IF NOT EXISTS idx_user_preferences_user_key ON user_preferences(user_id, preference_key);
|