Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration Error #67

Open
ughstudios opened this issue Aug 12, 2019 · 9 comments
Open

Migration Error #67

ughstudios opened this issue Aug 12, 2019 · 9 comments

Comments

@ughstudios
Copy link

ArgumentError: Algorithm must be one of the following: :default, :copy, :inplace

I get this when I simply run rails db:migrate

@chevinbrown
Copy link
Contributor

chevinbrown commented Aug 12, 2019

@BDoom can you provide more info?
What version of rails?
Is this the latest gem version?
What database?

@ughstudios
Copy link
Author

I'm using mysql, the latest gem version, and rails 5.2.3 ruby version 2.6.3.

@chevinbrown
Copy link
Contributor

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?

@ughstudios
Copy link
Author

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?

@ughstudios
Copy link
Author

ughstudios commented Aug 12, 2019

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

@ughstudios
Copy link
Author

Would it be default, copy, or in place?

@ughstudios
Copy link
Author

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

@chevinbrown
Copy link
Contributor

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. :/

@ughstudios
Copy link
Author

I just installed postgres and it worked fine. I'm not really attached to mysql, it was just easiest to install.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants