Moved the check for the rails test environment into rails/test_unit so that you
can select frameworks separately when running rake test.
Revert "Revert "`belongs_to :touch` behavior now touches old association when transitioning to new association" until a proper fix is found for #10197"

This reverts commit 7389df139a35436f00876c96d20e81ba23c93f0a.

Conflicts:
	activerecord/test/cases/timestamp_test.rb
added test cases for #10197
Reset the primary key for other tests
Removed unused associations
Lookup the class at runtime, not when the association is built

Trying to lookup the parent class when the association is being built
runs the risk of generating uninitialized constant errors because
classes haven't been fully defined yet. To work around this we look up
the class at runtime through the `association` method.

Fixes #10197.
Merge pull request #10256 from wangjohn/moving_check_for_test_environment_into_rails_env

Moved the check for the rails test environment into rails.rb

Closes #10238
Remove code duplication
Merge pull request #10331 from neerajdotname/exec-migration-in-transaction

Remove code duplication