sequelize: Association between tables in different DBs ignored
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
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 2
- Comments: 26 (10 by maintainers)
¿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.