I'm building an integration software between two different systems. I have Clients in a database, and Groups in another. One Client can be in multiple groups, and one group can have multiple clients. So, I created an intermediate table named as clients_groups
to represent this relation.
My models are so:
DB1 = Sequel.connect(adapter: 'postgresql'...)
DB2 = Sequel.connect(adapter: 'tinytds'...)
class Client < Sequel::Model
set_dataset DB1[:clients]
many_to_many :groups, left_ley: :client_id, right_key: :group_id, join_table: :clients_groups, left_primary_key_column: :id
end
class Group < Sequel::Model
set_dataset DB2[:groups]
many_to_many :clients, left_ley: :group_id, right_key: :client_id, join_table: :clients_groups, right_primary_key_column: :id
end
This statement works:
Client.last.groups
While this throws an error:
Group.last.clients # => Sequel::DatabaseError: TinyTds::Error: Invalid object name 'CLIENTS_GROUPS'
What am I doing wrong?