sequelize/sequelize — pull request #744 by SoEasy (2013-07-03 11:03:44+00:00)
Title: Added option 'primaryKey' for HasOne options

If we are working with an existing database, it can happen when foreignKey does not depend on the 'id' column, but from a different column. This commit adds a key 'primaryKey' to options in .hasOne method.
If we add primaryKey option - value of the condition is not taken from the column 'id', but is taken from the specified column.
Using:
ObjectHistory.hasOne(ObjectInfo, {as: 'ObjectInfo', foreignKey: 'id', primaryKey: 'ObjectInfoID'});