I recently tried to setup ScrumPad on my new laptop windows 7 (yes, I know not an ideal environment for Ruby on Rails. The peril of doing so is a topic for another blog) from scratch and stumbled on migration decay issue. We usually don't need to set up our projects from scratch. Every now and then we would. Whoever is doing the setup from scratch would go ahead fix any issues that might crop up in our migration scripts.
We are happily doing everything through migration just because we can- from managing incremental change in schema, to loading seed data, to migrating data due to schema changes. Over time we accumulated 498 scripts! And we have many non-backward compatible changes along the way.
This got me thinking whether we are following the best practices around migration. Here are a few things that we decided to follow going forward based on my findings:
1. Incremental changes. We will only use migration to manage incremental changes to schema. Nothing more.
2. Loading seed data. We should not be using migration script to load seed data. Instead we will use ActiveRecord to load data. If we have a lot of seed data, we would use database ETL tool instead, which would be faster.
3. Irreversible schema changes. We should through ActiveRecord::IrreversibleMigration exception from the "down" method when changes are irreversible. This is recommended by the Rails core team. We were not doing this. Even if we can revert back the schema changes, we won't be able to revert back the data changes that we do as a result of schema changes. So, why bother?
4. New database setup. We should use schema.rb to setup the database from scratch, instead of using migration scripts. We should store this in the repository and always keep it up-to-date.
5. Periodic baselining. When we reach a point of irreversible change, we should re-baseline migration script to start from that point going forward. That is we discard old migration scripts, and start with the schema.rb as the new baseline schema from that point forward.
6. Migration versioning. Although the use of sequential numbers may cause conflicting migrations (migration script with the same version), we still like this over the timestamp-based versioning introduced with Rails 2. We just synchronize among ourselves (communication!) to make sure we do not step on each other's toe. As a result, we can easily understand the logical ordering among the scripts (hence the assumed dependencies, if any).
What do you think of our approach to Rails migration? What guideline (if any) do you follow with your rails migration?
Friday, February 19, 2010
Thursday, February 18, 2010
Introduction to Ruby on Rails: A Beautiful Framework for Today’s Web
In last one month we presented two seminars on above topic. Fuad, Faruk and Arif presented the seminars. Hasan showed how to build an application quickly from the scratch. Here is his slides. The one we presented is embedded below. One can also download this and many other interesting materials from our website tech corner.
Introduction to RoR: A beautiful framework for today’s web
Visit our photo albums to see how the seminars went.
Tuesday, February 2, 2010
Welcome 2010- agile way of nature and life
Good bye 2009 and welcome 2010.
What better way to start a promising and exciting year than getting in touch with the wild yet agile nature and appreciate it. To rejuvenate ourselves with energy and promises, and to learn the agile way of nature -- we escaped to the nature with our family for a few days from our busy life in the office this January.
Lawachara is a national reserve forest located in Sreemangal, which is also famous for the highest rainfall, orange orchard, export quality tea, indigenous people like Manipuri and Khasia, and the reserved natural lake - Baikka in the vicinity.
We started our journey early in the morning.
The tea garden was fabulous.
The landscape was breath-taking …
Not quite was the navigation through it.
But there were hands to help
and little things that made us laugh.
The woods were dark and deep
and dangerous species lurking around,

but we had miles to go before we sleep
as we knew 2010 is a year to fly
on the wings of our weaved dream.
[We took loads of pics visit our Facebook Fanpage to see more.]
What better way to start a promising and exciting year than getting in touch with the wild yet agile nature and appreciate it. To rejuvenate ourselves with energy and promises, and to learn the agile way of nature -- we escaped to the nature with our family for a few days from our busy life in the office this January.
Lawachara is a national reserve forest located in Sreemangal, which is also famous for the highest rainfall, orange orchard, export quality tea, indigenous people like Manipuri and Khasia, and the reserved natural lake - Baikka in the vicinity.
We started our journey early in the morning.

The tea garden was fabulous.

The landscape was breath-taking …

Not quite was the navigation through it.

But there were hands to help

and little things that made us laugh.

The woods were dark and deep

and dangerous species lurking around,


but we had miles to go before we sleep

as we knew 2010 is a year to fly

on the wings of our weaved dream.

[We took loads of pics visit our Facebook Fanpage to see more.]
Subscribe to:
Posts (Atom)