Engine: fixes #3342 - foreign keys migration