Reopening the class instead of assuming it is already defined

Since https://github.com/rails/rails/commit/d0bb43d621c471659d03504f48f0197c0ae3b57c
The this class is not defined inside the on_load hook of Active Record
when checking for pending migrations.

Closes rails/rails#10109