Ruby on Rails: Migration Status

After a short pause, I’m back in the Ruby on Rails world. While I was looking for something related to migrations, I found a useful rake task called db:migrate:status:

~/Code/ruby/rails tutorial % bundle exec rake db:migrate:status
(in /Users/zsolt/Code/ruby/rails tutorial)

database: db/development.sqlite3

 Status   Migration ID    Migration Name
--------------------------------------------------
   up     20110403160633  Create users
   up     20110403171302  Add email uniqueness index
   up     20110404110551  Add password to users
   up     20110404115405  Add salt to users
   up     20110412112920  Add admin to users
  down    20110414092620  Create microposts

It seems that my development database isn’t the latest. Of course, the db:version could do the trick too, but the db:migrate:status provides more information. If you are interested in the status of other databases, use the RAILS_ENV variable:

~/Code/ruby/rails tutorial % RAILS_ENV=production bundle exec rake db:migrate:status

comments powered by Disqus