Class: InterestBlockingsMigration

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

Instance Method Summary collapse

Instance Method Details

#changeObject



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

def change
  create_table :blockings do |t|
    t.belongs_to :blocker, polymorphic: true, null: false
    t.belongs_to :blockee, polymorphic: true, null: false

    t.timestamps
  end

  add_index :blockings, [:blocker_id, :blocker_type], name: :index_blockings_blocker
  add_index :blockings, [:blockee_id, :blockee_type], name: :index_blockings_blockee
  add_index :blockings, [:blocker_id, :blocker_type, :blockee_id, :blockee_type], unique: true, name: :index_blockings_uniqueness
end