1
0
Fork 0
dokkan-data-rails/db/migrate/20151103193404_add_links_counter_cache_to_cards.rb

16 lines
368 B
Ruby
Raw Permalink Normal View History

2015-11-03 14:36:44 -05:00
class AddLinksCounterCacheToCards < ActiveRecord::Migration
def up
add_column :cards, :links_count, :integer, default: 0, null: false
PaperTrail.whodunnit = 1
2015-11-03 14:36:44 -05:00
Card.reset_column_information
Card.find_each do |card|
card.update_attribute(:links_count, card.links.count)
end
end
def down
remove_column :cards, :links_count
end
end