Class: CreateRecommendations

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/acts_as_recommended/tables/templates/migrations/create_recommendations.rb

Class Method Summary collapse

Class Method Details

.downObject



16
17
18
# File 'lib/generators/acts_as_recommended/tables/templates/migrations/create_recommendations.rb', line 16

def self.down
  drop_table :recommendations
end

.upObject



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/generators/acts_as_recommended/tables/templates/migrations/create_recommendations.rb', line 2

def self.up
  create_table :recommendations do |t|
    t.references :recommendable, :polymorphic => true, :null => false
    t.references :owner, :null => false
    t.boolean    :recommendation, :null => false
    
    t.timestamps
  end
  
  add_index :recommendations, [:recommendable_type, :recommendable_id],  :name => 'idx_recommendations'
  add_index :recommendations, [:recommendable_type, :recommendable_id, :owner_id], :unique => true, :name => 'idx_recommendations_user'
  add_index :recommendations, [:recommendable_type, :recommendable_id, :recommendation],  :name => 'idx_recommendations_type'
end