Skip to content

Commit

Permalink
Correct index_exists? method
Browse files Browse the repository at this point in the history
  • Loading branch information
chevinbrown committed Dec 1, 2018
1 parent bd13a1f commit 1b776c8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion db/migrate/4_add_unique_index_to_friendships.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ class AddUniqueIndexToFriendships < ActiveRecord::Migration; end
disable_ddl_transaction!

def self.up
add_index :friendships, [:friendable_id, :friend_id], unique: true, algorithm: :concurrently unless index_exists? (:friendable_id, :friend_id)
return if index_exists?(:friendships, [:friendable_id, :friend_id])

add_index :friendships, [:friendable_id, :friend_id], unique: true, algorithm: :concurrently
end

def self.down
Expand Down

0 comments on commit 1b776c8

Please sign in to comment.