What are the brackets [5.1] after ActiveRecord Migration and how does it work? [duplicate]

This is the new migration versioning introduced with Rails 5. The number indicates the migration version the migration was created with, in this case version 5.1 and should be used with Rails versions >= 5.0.

This is a class function def self.[](version) of the ActiveRecord::Migration, which calls Compatibility.find(version) and is used for backward compatibility.

Here are the code references from GitHub:

Leave a Comment