Sha256: a6271e7097de8998241159707a67159f696085285f49353f0280d1d2b8746612

Contents?: true

Size: 543 Bytes

Versions: 58

Compression:

Stored size: 543 Bytes

Contents

# frozen_string_literal: true

class AddCommentableCounterCacheToDebates < ActiveRecord::Migration[5.2]
  def change
    add_column :decidim_debates_debates, :comments_count, :integer, null: false, default: 0, index: true
    Decidim::Debates::Debate.reset_column_information

    # rubocop:disable Rails/SkipsModelValidations
    Decidim::Debates::Debate.includes(:comments).find_each do |debate|
      debate.update_columns(comments_count: debate.comments.not_hidden.count)
    end
    # rubocop:enable Rails/SkipsModelValidations
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
decidim-debates-0.26.8 db/migrate/20200827154116_add_commentable_counter_cache_to_debates.rb
decidim-debates-0.27.4 db/migrate/20200827154116_add_commentable_counter_cache_to_debates.rb
decidim-debates-0.27.3 db/migrate/20200827154116_add_commentable_counter_cache_to_debates.rb
decidim-debates-0.26.7 db/migrate/20200827154116_add_commentable_counter_cache_to_debates.rb
decidim-debates-0.26.5 db/migrate/20200827154116_add_commentable_counter_cache_to_debates.rb
decidim-debates-0.27.2 db/migrate/20200827154116_add_commentable_counter_cache_to_debates.rb
decidim-debates-0.27.1 db/migrate/20200827154116_add_commentable_counter_cache_to_debates.rb
decidim-debates-0.26.4 db/migrate/20200827154116_add_commentable_counter_cache_to_debates.rb
decidim-debates-0.27.0 db/migrate/20200827154116_add_commentable_counter_cache_to_debates.rb
decidim-debates-0.26.3 db/migrate/20200827154116_add_commentable_counter_cache_to_debates.rb
decidim-debates-0.27.0.rc2 db/migrate/20200827154116_add_commentable_counter_cache_to_debates.rb
decidim-debates-0.27.0.rc1 db/migrate/20200827154116_add_commentable_counter_cache_to_debates.rb
decidim-debates-0.26.2 db/migrate/20200827154116_add_commentable_counter_cache_to_debates.rb
decidim-debates-0.26.1 db/migrate/20200827154116_add_commentable_counter_cache_to_debates.rb
decidim-debates-0.26.0 db/migrate/20200827154116_add_commentable_counter_cache_to_debates.rb
decidim-debates-0.26.0.rc2 db/migrate/20200827154116_add_commentable_counter_cache_to_debates.rb
decidim-debates-0.26.0.rc1 db/migrate/20200827154116_add_commentable_counter_cache_to_debates.rb
decidim-debates-0.25.2 db/migrate/20200827154116_add_commentable_counter_cache_to_debates.rb
decidim-debates-0.25.1 db/migrate/20200827154116_add_commentable_counter_cache_to_debates.rb
decidim-debates-0.25.0 db/migrate/20200827154116_add_commentable_counter_cache_to_debates.rb