Feature(s) impacted
I’m trying to add a relationship in a table called reward
which is in the database called rewards
. The relationship is of the belongsTo
. I’ve tried to do something like the following in the reward
model:
Reward.belongsTo(models.merchant, {
foreignKey: {
name: 'merchantIdKey',
field: 'merchant_id',
},
as: 'merchant',
tableName: 'emma.merchant',
});
Also added the following to the schema for the reward
model:
{ "field": "merchant", "type": "Number", "defaultValue": null, "enums": null, "integration": null, "isFilterable": true, "isPrimaryKey": false, "isReadOnly": false, "isRequired": false, "isSortable": true, "isVirtual": false, "reference": "merchant.id", "inverseOf": null, "relationship": "BelongsTo", "validations": [] }
But I get the following error:
[forest] 🌳🌳🌳 Unexpected error: Table 'rewards.merchant' doesn't exist
{
"name": "SequelizeDatabaseError",
"parent": {
"code": "ER_NO_SUCH_TABLE",
"errno": 1146,
"sqlState": "42S02",
"sqlMessage": "Table 'rewards.merchant' doesn't exist",
...
Which is accurate since the merchant
table is in the emma
DB rather than rewards
. Any suggestions would be greatly appreciated.
Thanks,
Sahil
Observed behavior
Can’t add relationship from a table in another DB.
Expected behavior
Able to add a relationship from a table in another DB.
Context
- Project name: Emma
- Team name: Rewards
- Environment name: Development | sahilmemon
- Agent technology: Node.js
- Agent (forest package) name & version: forest-cli@5.0.9, forest-express-sequelize@9.0.0
- Database type: MySQL
- Recent changes made on your end if any: Updated a model and schema in the codebase.