Fixes: #1922 Moving foreignKey handling to plugin