fixes #2400 continue - fixes to foreign key constraints commit c0005dcd68