Readded the foreign key support which is commented out