Wednesday, October 22, 2008

Facing Issues with migrating rails from 1.2.5 to 2.1.0

We identified some issues while porting one of our projects from rails 1.2.5 to 2.1.0

Rails removed some functions which were deprecated

This affected 3rd party libraries as well as the application to be migrated. As a result we had to tweak some the libraries

Application was refactored

  • rails 1.2.5 supported Project.find_all( :joins=>["…"], ...) which is now Project.find( :all, :joins=>"...", ...)
  • render '/controller/action' has changed to, render :controller =>'controller', :action =>'action'

Some libraries are tweaked

  • In-Place-Editing see

Regarding Migration

The way rails maintained migration information(latest migration) has changed. Rails 1.2.5 kept latest migration version that is synchronized with database in "schema_info" table. And now it stores in "schema_migrations" table.

" schema_info" has only one row keeping the latest migration synchronized with database. "schema_migrations" has entry for each migration that ran to synchronize the database.

So if we are migrating to rails 2.1 then we should run an insert script to create entries for each migration in "schema_migrations".

Faced problem with rake 0.8.3

We found that rake 0.8.3 creates problem in Linux, so we had to revert the rails version to 0.8.2. Rails 2.1.0 runs with rake 0.8.2.

Faced problem with ActiveMessaging

We faced some problem regarding ActiveMessaging. Here is a group discussion that might help. We fixed it by modifying support.rb in activemessaging according to the latest patch, can be found here

Rails 2.1.0 specifies default character set for database

Rails 2.1.0 sets utf-8 as default database encoding. So some expected result might misbehave.

Faced issues with folder based fixtures

Our project had lots of scenario while testing each controller or model. That is why we used folder based fixture so we can concentrate on particular fixture while testing particular model.

We defined fixture path like,

def fixture_path

File.join(File.dirname(__FILE__), "../fixtures/test_model")

end

It worked in rails 1.2.5. But it is misbehaving in rails 2.1.0. So we introduced scenario plugin to resolve that issue.