octopus icon indicating copy to clipboard operation
octopus copied to clipboard

When running `using_all`, is there any way to get which instance we're on?

Open suthanbala opened this issue 6 years ago • 1 comments

The setup: I have multiple databases of the same schema. Each database represent the data for different sites. I want to iterate through each of the instances and print out the user count along with the shard name. How can I do that?

This is the code I have so far:

Octopus.using_all do
      users = User.all
      ap @shard  # This doesn't work
      ap users.length
    end

suthanbala avatar Apr 04 '18 14:04 suthanbala

What about User.connection.current_shard ?

sekiyama58 avatar Apr 10 '18 05:04 sekiyama58