Skip to content

Commit

Permalink
Merge pull request #1 from edcast/rails5.2
Browse files Browse the repository at this point in the history
Rails5.2
  • Loading branch information
nileshmamidi authored Mar 16, 2020
2 parents 43c367e + 1b9a0c4 commit c9927c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
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

0 comments on commit c9927c3

Please sign in to comment.