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

made changes to support rails 5.2 #550

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/octopus/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def init_with(coder)

return obj unless Octopus.enabled?
return obj if obj.class.connection_proxy.current_model_replicated?
return obj unless coder['attributes'].present?

current_shard_value = coder['attributes']['current_shard'].value if coder['attributes']['current_shard'].present? && coder['attributes']['current_shard'].value.present?

Expand Down
9 changes: 6 additions & 3 deletions lib/octopus/proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ def clear_all_connections!

def connected?
shards.any? { |_k, v| v.connected? }
rescue NoMethodError
proxy_config.reinitialize_shards
retry
end

def should_send_queries_to_shard_slave_group?(method)
Expand All @@ -192,15 +195,15 @@ def send_queries_to_slave_group(method, *args, &block)
def current_model_replicated?
replicated && (current_model.try(:replicated) || fully_replicated?)
end

def initialize_schema_migrations_table
if Octopus.atleast_rails52?
select_connection.transaction { ActiveRecord::SchemaMigration.create_table }
else
else
select_connection.initialize_schema_migrations_table
end
end

def initialize_metadata_table
select_connection.transaction { ActiveRecord::InternalMetadata.create_table }
end
Expand Down