Class: InterestFollowingsMigration

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

Instance Method Summary collapse

Instance Method Details

#changeObject



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

def change
  create_table :followings do |t|
    t.belongs_to :follower, polymorphic: true, null: false
    t.belongs_to :followee, polymorphic: true, null: false
    t.string :status, null: false

    t.timestamps
  end

  add_index :followings, [:follower_id, :follower_type], name: :index_followings_follower
  add_index :followings, [:followee_id, :followee_type], name: :index_followings_followee
  add_index :followings, [:follower_id, :follower_type, :followee_id, :followee_type], unique: true, name: :index_followings_uniqueness
end