Added test for `ForeignKey` as primary key
Fix history record creation
Merge pull request #145 from treyhunner/foreignkey-primarykey

Fix primary key handling when primary key is a `ForeignKey`