Can I connect between tables in different databases using Sequel?
I am creating software for integration between two different systems. I have Clients in a database and Groups in another. One Client can be in several groups, and one group can have several clients. So, I created a named intermediate table clients_groups
to represent this relationship.
My models are as follows:
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 is throwing an error:
Group.last.clients # => Sequel::DatabaseError: TinyTds::Error: Invalid object name 'CLIENTS_GROUPS'
What am I doing wrong?
+3
source to share
No one has answered this question yet
Check out similar questions: