Making Composite Migrations work on Rails 1.2

Posted by admin, Tue Apr 17 03:49:51 UTC 2007

I was attempting to use the Composite Migrations plugin when I discovered that it didn’t work with Rails 1.2. 
<br />
$ rake db:migrate
(in /Users/lori/Projects/workspace/eTriever)
== AddCurrentSearches: migrating ==============================================
-- create_table(:current_searches, {:primary_key=&gt;[:user_id, :type]})
rake aborted!
undefined method `type_to_sql' for #<activerecord ::ConnectionAdapters::ColumnDefinition:0x7fe3740>
</activerecord>


It only took a couple of minutes of spelunking to discover the fix.  Inside ‘composite_migrations’, you need to change the call
type_to_sql
to
base.type_to_sql
Done.  Works now.
lori@kwigger ~/etriever
$ rake db:migrate
(in /Users/lori/Projects/workspace/eTriever)
== AddCurrentSearches: migrating ==============================================
-- create_table(:current_searches, {:primary_key=&gt;[:user_id, :type]})
&nbsp;&nbsp; -&gt; 0.0271s

Filed Under: | Tags:

Comments

  1. Martijn 06.07.07 / 22PM
    Thank you. Saved my day!
  2. Chris Bloom 09.26.07 / 01AM
    Thanks! I was going crazy at 4:00 am this morning trying to get composite keys to work, but your patch finally got it working (and let me go to bed) :)

Have your say

A name is required. You may use HTML in your comments.