Anatomy of a Migration
Migrations are subclasses of the Rails class ActiveRecord::Migration. When necessary, migrations can contain up and down methods:
|||class SomeMeaningfulName < ActiveRecord::Migration|
The name of the class, after all uppercase letters are downcased and preceded by an underscore, must match the portion of the filename after the version number. For example, the previous class could be found in a file named 20160330000017_some_meaningful_name.rb. No two migrations can contain classes with the same name.
The up method is responsible for applying the schema changes for this migration, while the down method undoes those changes. Let’s make this more concrete. ...