Prior to Rails 2.1, the migrations were sequenced via a simple numbering scheme baked into the name of the migration file, and automatically handled by the migration generator.Each migration received a sequential number. There were many inconveniences inherent in that approach, especially in team environments where two developers could check in a migration with the same sequence number. Thankfully those issues have been
eliminated by using timestamps to sequence migrations.
Migrations that have already been run are listed in a special database table that Rails
maintains. It is named schema_migrations and only has one column:
mysql> desc schema_migrations;
+———+————–+——+—–+———+——-+
| Field| Type| Null | Key | Default | Extra |
+———+————–+——+—–+———+——-+
| version | varchar(255) | NO| PRI | NULL|
+———+————–+——+—–+———+——-+
1 row in set (0.00 sec)
When you pull down new migrations from source control, rake db:migrate will check
the schema_migrations table and execute all migrations that have not yet run (even if
they have earlier timestamps than migrations that you’ve added yourself in the interim).