Sha256: eeb379f5a13df97242328d065c8c2254a6b13df64a32f48ac4ee8b58c3699aaa
Contents?: true
Size: 549 Bytes
Versions: 2
Compression:
Stored size: 549 Bytes
Contents
class AddRatingToProducts < ActiveRecord::Migration def self.up add_column :products, :avg_rating, :decimal, :default => 0.0, :null => false, :precision => 7, :scale => 5 add_column :products, :reviews_count, :integer, :default => 0, :null => false Product.reset_column_information Product.all.each do |p| Product.update_counters p.id, :reviews_count => p.reviews.length p.recalculate_rating end end def self.down remove_column :products, :reviews_count remove_column :products, :avg_rating end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spree_reviews-0.50.1 | db/migrate/20110406083603_add_rating_to_products.rb |
spree_reviews-0.50.0 | db/migrate/20110406083603_add_rating_to_products.rb |