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