-- Índices para acelerar o board Kanban e unread de unread/unread

CREATE INDEX idx_ticket_created_at ON ptk_ticket (created_at);
CREATE INDEX idx_ticket_task_at ON ptk_ticket (task_at);
CREATE INDEX idx_ticket_status_created ON ptk_ticket (status_id, created_at);
CREATE INDEX idx_ticket_project_status_created ON ptk_ticket (project_id, status_id, created_at);

CREATE INDEX idx_chat_ticket_unread ON amb_chat_messages (table_related, table_id, is_read, create_user);
CREATE INDEX idx_chat_table_related_id ON amb_chat_messages (table_related, table_id);

CREATE INDEX idx_ticket_task_hours_date ON ptk_ticket_task_hours (date);
CREATE INDEX idx_ticket_task_hours_ticket_date ON ptk_ticket_task_hours (ticket_id, date);
