Class: FavorableMigration

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

Class Method Summary collapse

Class Method Details

.downObject



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

def self.down
  drop_table :favorites
end

.upObject



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

def self.up
  create_table :favorites do |t|
    t.references :favorable, polymorphic: true
    t.references :favoriter, polymorphic: true
    
    t.timestamps
  end

  add_index :favorites, [:favorable_id, :favorable_type]
  add_index :favorites, [:favoriter_id, :favoriter_type]
end