fixes #2400 migration to remove orphaned records and add foreign keys constraints to database tables
squash this commit