Class: CreateRatings

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

Class Method Summary collapse

Class Method Details

.downObject



17
18
19
# File 'lib/generators/spleen/templates/migration.rb', line 17

def self.down
  drop_table :ratings
end

.upObject



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/generators/spleen/templates/migration.rb', line 3

def self.up
  create_table(:ratings) do |t|
    t.column :ratetor_id, :integer, :null => false
    t.column :ratetor_type, :string, :null => false
    t.column :rate, :float, :null => false
    t.column :rateable_id, :integer, :null => false
    t.column :rateable_type, :string

    t.timestamps
  end

  add_index :ratings, [:rateable_id, :rateable_type]
end