This is a very minor refactor of the ActiveRecord::SchemaMigration class.
No tests added and no documentation modified since this is a small refactor.
Minor refactor of ActiveRecord::SchemaMigration to remove references …
…to Base, override table_exists method, and switch to preferred style for class method definitions.
Can we have a benchmark test for this?
@aditya-kapoor Here is the benchmark I ran, using the same pattern as activerecord/examples/performance.rb: https://gist.github.com/kylerippey/5663887
I performed three runs on each branch with the following results:
747.8 (±7.4%) i/s - 14874 in 20.003392s
741.0 (±8.6%) i/s - 14697 in 19.993949s
768.5 (±7.4%) i/s - 15264 in 19.975956s
Average: 752.43 i/s
744.2 (±7.9%) i/s - 14784 in 20.000572s
746.9 (±7.8%) i/s - 14839 in 19.993636s
766.9 (±7.6%) i/s - 15264 in 20.020892s
Average: 752.67 i/s
Additionally, I noticed that "SchemaMigration.table_exists?" does not currently work as expected in rails master due to the fact that the ActiveRecord::Base implementation is passed through schema_cache. This is the current behavior:
ActiveRecord::SchemaMigration.table_exists? # returns false in rails master
ActiveRecord::Base.connection.table_exists?(ActiveRecord::SchemaMigration.table_name) # returns true
This change makes table_exists? work as expected by bypassing schema_cache.