Migrator assumes Lotus::Model.configuration and ignores dupes

So I’ve encountered something that became an issue for me and since I don’t know whether this is by design or oversight, thought I’d bring it here.

** Background **

I’m working on a gem that will live side by side with another lotus app. This gem’s responsibility is to talk to a external database to build some associations with objects in the including app, based on their id’s etc…

Since the gem will be talking to a different database, it must have it’s own configuration. And obviously because the including app would already have a Lotus::Model configuration, I dupe it to avoid conflicts.

This allows me to query both databases (the one the app is meant to use and the one that holds the associations) separately and compose the associations.

** The problem **

Because the Migrator module assumes that the configuration it should use for its migrations is under Lotus::Model.configuration, when I try running MyGem::Model::Migrator.migrate, it actually tries to migrate the wrong thing.

module MyGem
  Model = Lotus::Model.dupe
 
 # ...

  def setup
    Model.configure do
      adapter ...
      mapping ...
    end
    Model::Migrator.migrate # => This will fail because it won't use this config
  end

end

Looking at migrator.rb I can see this:

module Lotus
  module Model
    ...
      module Migrator
        ...
        def self.configuration
          Model.configuration
        end
        ...
      end
   end
end

Obviously since this method lives in Lotus::Model::Migrator, Model in this context would result in Lotus::Model which again, holds the base config and not my duped one.

This to looks like an oversight to me, as it wouldn’t make sense to make it possible to have to complete different configurations and have them act on different databases with different collections and limiting migrations to a single configuration.

I wanted to get the ball rolling and discuss whether this is something that should be looked at/fixed or not.

Please let me know your thoughts.

Thanks

Note: Sorry but the code bits look fine on the preview and terrible here… dont know why. bug on discuss?