Foreign keys for pg broken in loopback 3
carlosconnected opened this issue · 2 comments
Description/Steps to reproduce:
I have the following models:
{
"name": "RawMaterial",
"base": "PersistedModel",
"options": {
"foreignKeys": {
"idInjection": false,
"fk_rawMaterial_rawMaterialTypeId": {
"name": "fk_rawMaterial_rawMaterialTypeId",
"entity": "RawMaterialType",
"entityKey": "id",
"foreignKey": "rawMaterialTypeId"
}
}
}
}
{
"name": "RawMaterialType",
"base": "PersistedModel",
"options": {
"idInjection": false
},
"properties": {
"id": {
"type": "number",
"id": true,
"required": true
}
}
}
I keep getting the following error: error: column "rawMaterialTypeId" referenced in foreign key constraint does not exist
when running:
dataSource.autoupdate('RawMaterialType', (err, result) => {
if (err) throw err;
dataSource.autoupdate('RawMaterial', (err, result) => {
if (err) throw err;
});
};
My understanding is that this is caused because the RawMaterial
does not exist yet. But this is definitely a bug. It works well with the MySQL connector with its slightly different syntax.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS
file at the top-level of this repository.