Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20150113001834_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb « migrate « ci « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8edb508078131059ac506257527d5dc02bad67be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# This migration comes from acts_as_taggable_on_engine (originally 3)
class AddTaggingsCounterCacheToTags < ActiveRecord::Migration
  def self.up
    add_column :tags, :taggings_count, :integer, default: 0

    ActsAsTaggableOn::Tag.reset_column_information
    ActsAsTaggableOn::Tag.find_each do |tag|
      ActsAsTaggableOn::Tag.reset_counters(tag.id, :taggings)
    end
  end

  def self.down
    remove_column :tags, :taggings_count
  end
end