Reputation: 11890
I get that rails uses timestamps in the migration filenames. How does it utilize those to determine what migrations have been run so far and what still needs to be run? Is there a value stored somewhere that lets it know the last migration that was run?
Upvotes: 2
Views: 111
Reputation: 13952
In your database, there's a table called schema_migrations
that keeps track of it. It's maintained automatically by rails, and has a single column called version
. That column holds the date-time stamp of a migration, and each row represents a migration that's been already run.
So, Rails can look at all your 'migration' files in your app, figure out which ones do not yet have a corresponding row in the schema_migrations
table, and run them (adding a new row to the schema migrations table, for each migration, as it runs)
Here's an example of the content of a schema_migrations
table.
Upvotes: 3