Class: CreateRatingCaches

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/letsrate/templates/cache_migration.rb

Class Method Summary collapse

Class Method Details

.downObject



15
16
17
# File 'lib/generators/letsrate/templates/cache_migration.rb', line 15

def self.down
  drop_table :rating_caches
end

.upObject



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/generators/letsrate/templates/cache_migration.rb', line 3

def self.up
  create_table :rating_caches do |t|
    t.belongs_to :cacheable, :polymorphic => true
    t.float :avg, :null => false
    t.integer :qty, :null => false
    t.string :dimension
    t.timestamps
  end

  add_index :rating_caches, [:cacheable_id, :cacheable_type]
end