mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-09-22 02:19:59 +03:00
Added extra handling for errors when adding foreign key
- this section of code handles the errors that arise when we add a foreign key to a table - locally, I get different errors than the one listed - `ER_FK_DUP_KEY` and `ER_FK_DUP_NAME` - I've been trying to find a good source for what each code is but it looks highly likely to be differences in DB engines - we should probably handle these errors anyway because we don't want migrations to error out
This commit is contained in:
parent
1cc38733ba
commit
11f64e91c0
@ -197,7 +197,7 @@ async function addForeign({fromTable, fromColumn, toTable, toColumn, cascadeDele
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
if (err.code === 'ER_DUP_KEY') {
|
||||
if (err.code === 'ER_DUP_KEY' || err.code === 'ER_FK_DUP_KEY' || err.code === 'ER_FK_DUP_NAME') {
|
||||
logging.warn(`Skipped adding foreign key from ${fromTable}.${fromColumn} to ${toTable}.${toColumn} - foreign key already exists`);
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user