3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/generators/acts_rateable/templates/migration.rb', line 3
def self.up
create_table :ar_rates do |t|
t.references :resource, :polymorphic => true, :null => false
t.references :author, :polymorphic => true, :null => false
t.decimal :value, :default => 0
t.timestamps
end
add_index :ar_rates, [:resource_id, :resource_type]
add_index :ar_rates, [:author_id, :author_type]
create_table :ar_ratings do |t|
t.references :resource, :polymorphic => true, :null => false
t.string :type
t.integer :total, :default => 0
t.integer :sum, :default => 0
t.decimal :average, :default => 0
t.decimal :estimate, :default => 0
t.timestamps
end
add_index :ar_ratings, [:resource_id, :resource_type]
end
|