mi_plan update fixes & add new foreign_key
generate schema
on intermediate_report generation retry query after reconnecting the database
Merge branch 'bug_10358_and_9843' into staging

Conflicts:
	db/schema.rb
looks like this has been removed manually on the database and not by a migration
fix for error_field for nil class error on SQL exception
structure.sql is causing errors in production when migrating
override a rake task correctly
correctly override db:structure:dump so it doesn't cause issues on the VMs