Open ughstudios opened 5 years ago
@Bdoom can you provide more info? What version of rails? Is this the latest gem version? What database?
I'm using mysql, the latest gem version, and rails 5.2.3 ruby version 2.6.3.
That's definitely a bug. I probably won't have time to get to the mysql version of it for a bit. Would you feel comfortable offering a PR?
I would if I can find the solution first. I think it's just this line: add_index :friendships, [:friendable_id, :friend_id], unique: true, algorithm: :concurrently
Do you know what I need to change?
Entire migration:
# This migration comes from has_friendship_engine (originally 4)
if ActiveRecord.gem_version >= Gem::Version.new('5.0')
class AddUniqueIndexToFriendships < ActiveRecord::Migration[4.2]; end
else
class AddUniqueIndexToFriendships < ActiveRecord::Migration; end
end
AddUniqueIndexToFriendships.class_eval do
disable_ddl_transaction!
def self.up
return if index_exists?(:friendships, [:friendable_id, :friend_id])
add_index :friendships, [:friendable_id, :friend_id], unique: true, algorithm: :concurrently
end
def self.down
return unless index_exists?(:friendships, [:friendable_id, :friend_id])
remove_index :friendships, [:friendable_id, :friend_id]
end
end
Would it be default, copy, or in place?
Looks like :concurrently is simply only for Postgres databases actually. I think I could just use :inplace for now. But from what I can tell, :concurrently actually speeds up your database a lot lol. Maybe I'll move to postgres haha
Yeah, mysql & postgres have different strategies. If your db-size is relatively small, you'll be fine without concurrency and won't really notice a difference.
It looks like we'll need to set the algorithm dynamically depending on the db-type. :/
I just installed postgres and it worked fine. I'm not really attached to mysql, it was just easiest to install.
ArgumentError: Algorithm must be one of the following: :default, :copy, :inplace
I get this when I simply run rails db:migrate