Fixed automatic maintaining test schema to properly handle sql structure schema format.

Additionally:
* It changes `purge` task on `sqlite3` adapter to recreate database file, to
be consistent with other adapters.
* Adds `purge` step when loading from `schema.rb`

Conflicts:
	activerecord/CHANGELOG.md
	railties/test/application/test_test.rb
Merge pull request #16316 from rails/senny/purge_schema_maintenance

purge database before loading schema, take 2
Conflicts:
	activerecord/CHANGELOG.md
	activerecord/lib/active_record/tasks/database_tasks.rb
remove deprecation warning which is not yet issued.

This will be deprecated with `4.2`. [ci skip]
fix, mysql `db:purge` respects `Rails.env`.

Previously this method always established a connection to the test database.
This resulted in buggy behavior when combined with other tasks like
`bin/rake db:schema:load`.

This was one of the reasons why #15394 (22e9a91189af2c4e6217a888e77f22a23d3247d1)
was reverted:

> I’ve replicated it on a new app by the following commands: 1) rails
  generate model post:title, 2) rake db:migrate, 3) rake
  db:schema:load, 4) rails runner ‘puts Post.first’. The last command
  goes boom. Problem is that rake db:schema:load wipes the database,
  and then doesn’t actually restore it. This is all on MySQL. There’s
  no problem with SQLite.

  -- DHH

https://github.com/rails/rails/commit/22e9a91189af2c4e6217a888e77f22a23d3247d1#commitcomment-6834245

Conflicts:
	activerecord/CHANGELOG.md
Merge pull request #16739 from y-yagi/patch-6

[ci skip] Fix example code of ActiveRecord::FixtureSet.context_class
Merge pull request #16756 from huoxito/dont-mess-railties-default-order

Dont mess with default order engines load (4.1.6.rc1 regression)
Merge pull request #16795 from Peeja/methods-are-not-duplicable

Methods are not duplicable.
Conflicts:
	activesupport/CHANGELOG.md
	activesupport/test/core_ext/duplicable_test.rb
schema loading rake tasks maintain database connection for current env.

[Joshua Cody & Yves Senn]

Closes #16757.

Prior to this patch schema loading rake tasks had the potential to leak a
connection to a different database. This had side-effects when rake tasks
operating on the current connection (like `db:seed`) were chained.

Conflicts:
	activerecord/CHANGELOG.md
	activerecord/lib/active_record/tasks/database_tasks.rb
	activerecord/test/cases/tasks/database_tasks_test.rb
Enums shouldn't ruin people's anniversaries

Added a few more methods on Module/Class to the dangerous class methods
blacklist. (Technically, allocate and new are already protected currently because
we happen to redefine them in the current implantation.)

Closes #16792
remove unnecessary arel delegation on relations, which meant that depending on what code ran first, scopes named the same as any arel method may or may not get replaced by the arel method, which may or may not show up in tests.  keep the #ast delegation as that is commonly used, write out two other calls to it, one of which was already involved in the guts of arel.  fixes the old GH issue #7421.
Merge branch 'arel_delegation' into 4-1-stable