What is a Rails migration?

Answer

A migration is a Ruby file that describes a change to the database schema — creating/dropping tables, adding/removing columns, adding indexes. Migrations allow you to evolve your database schema over time in a version-controlled, reversible way. Run rails db:migrate to apply pending migrations and rails db:rollback to revert the last one. Each migration has an up (or change) method and optionally a down method. The schema.rb file is the authoritative snapshot of the current database schema.