From b96c57210ab1ef2da5cf24e50df497430d1878bd Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 8 Sep 2017 17:36:42 +0200 Subject: [PATCH] Followup improvement for issue#1394 - Reindex elastic search not possible because of /Twitter::NullObject. --- ...70908000001_fixed_twitter_ticket_article_preferences4.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/migrate/20170908000001_fixed_twitter_ticket_article_preferences4.rb b/db/migrate/20170908000001_fixed_twitter_ticket_article_preferences4.rb index 6529467f4..9b97fb7cd 100644 --- a/db/migrate/20170908000001_fixed_twitter_ticket_article_preferences4.rb +++ b/db/migrate/20170908000001_fixed_twitter_ticket_article_preferences4.rb @@ -1,12 +1,12 @@ -class FixedTwitterTicketArticlePreferences4 < ActiveRecord::Migration +class FixedTwitterTicketArticlePreferences4 < ActiveRecord::Migration[5.0] def up # return if it's a new setup return if !Setting.find_by(name: 'system_init_done') # find article preferences with Twitter::NullObject and replace it with nill to prevent elasticsearch index issue - article_type = Ticket::Article::Type.find_by(name: ['twitter status', 'twitter direct-message']) - article_ids = Ticket::Article.where(type_id: article_type.id).pluck(:id) + article_type_ids = Ticket::Article::Type.where(name: ['twitter status', 'twitter direct-message']).pluck(:id) + article_ids = Ticket::Article.where(type_id: article_type_ids).pluck(:id) article_ids.each { |article_id| article = Ticket::Article.find(article_id) next if !article.preferences