fixes #2400 migration to remove orphaned records and add foreign keys constraints to database tables
Fixes #2272 - added Capybara integration tests, but without javascripts tests