Like I mentioned in an earlier post, I really want to learn Ruby, so I can then dive into Ruby on Rails. Well, I decided to start moving along towards Rails, as I have a more clearer understanding of the Ruby language, its syntax and other goodies. I purchased the most awesome Rails book out there, Agile Web Development with Rails, a couple of months ago, but unfortunately I bought the first edition, which doesn't even cover Rails 1.0. With the announcement a few weeks ago of Rails 1.2, I wanted to play with those features that aren't covered in the book.
Looking around at the Rails Screencasts, I saw a nice little screencast about database migrations in Rails. Curious, I checked out that screencast, and was simply amazed at how easy it is to work with the database schema of your application in Rails. With the PHP applications I've developed over the years, this was one of the things that simply drove me crazy. Every time I did a change to the database in my development server, either adding a new column to a table, or deleting an existing table, I had to make a note to do it as well in the production server once the changes were complete. I can't tell you how many times I uploaded some new changes to the production server, told the users about the changes, then reading their semi-angry E-Mails about how the changes don't work at all, simply because I forgot to make the database changes.
With the migrations in Rails, once you have your schema set and the migrations in place, it's as easy as editing a text file, specifying the changes you want to make, run a simple rake db:migrate command, and presto - All your changes are made automatically to the database without any data loss! And just in case you decide against one of those changes, you can go to the previous migration you made, which will revert your database as it was before. It's really, really neat, and I don't know how I ever lived without the migrations.
I still have a lot more to know, as I started playing around with migrations myself last night. But honestly, this is a feature that I know will save a lot of my time, as well as cover my behind in case of emergency. And to think that this is only one of the apparently many benefits of Ruby on Rails. Now I'm more pumped up than ever to keep on reading about this most awesome framework. Maybe I'll finally be able to finish my first full Rails app ever soon, which is one of my short-term goals I started this year. It really is a beautiful thing.