question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Association between tables in different DBs ignored

See original GitHub issue

I have two tables. They belong to different databases.

export default db1.define(`hero`, {
teamId: {
    type: Sequelize.INTEGER
    ....
},
name; {
    type: Sequelize.STRING
}
....
}

export default db2.define(`team`, {
id: {
    type: Sequelize.INTEGER
},
name; {
    type: Sequelize.STRING
}
....
}

Then in another file, I associate hero with team like this in another file.

import Hero
import Team
Hero.hasOne(Team, {foreignKey: 'teamId'})

Now it is telling me that "ER_NO_SUCH_TABLE: Table 'db1.team' doesn't exist". It seems to be ignoring my db specification. Is this normal? And how should I counteract this? It should be trying to associate db1.hero with db2.team. Thanks.

Dialect: mysql __Database version: 5.6.31 __Sequelize version: ^3.14.2

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:26 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
alvaroquezadacommented, May 4, 2018

¿There is a solution for this issue? I have this problem I need to create an association between tables in two different databases on MySQL. if I use table1.hasOne(table2…) sequelize assumes both in the same database when it creates the SQL statement.

0reactions
papbcommented, Oct 13, 2019

This is a duplicate of #2089 as said above.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Relationships between tables from different databases not ...
HELP - Relationships are not working I am pulling data from one databse and trying to join that with a table from another...
Read more >
why there is databases with no RELATIONSHIP between their ...
I didn't ever read about ignoring RELATIONSHIPS in databases with tables that have logically relate to each other. My question is, Not defining ......
Read more >
Relationships between tables in a Data Model
A relationship is a connection between two tables of data, based on one column in each. A workbook can store each piece of...
Read more >
Eight Common Database Design Bad Practices - Toptal
Redundant fields and tables are a nightmare for developers, since they require business logic to keep many version of the same information up...
Read more >
Relational vs Non-Relational Databases - Pluralsight
The connection between the primary and foreign key then creates the “relationship” between records contained across multiple tables. This image ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found