Active migration gives undefined_method 'string_to_binary'

has anyone ever seen that:

c:\rails\test>rake migrate --trace
(in c:/rails/test)
** Invoke migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute migrate
rake aborted!
undefined method string_to_binary' for ActiveRecord::ConnectionAdapters::ColumnDefinition:Class c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/mysql_adapt er.rb:119:inquote’
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/sc
hema_statements.rb:245:in
add_column_options!' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/sc hema_definitions.rb:180:inadd_column_options!’
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/sc
hema_definitions.rb:169:in
to_s' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/sc hema_definitions.rb:249:in*’
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/sc
hema_definitions.rb:249:in
to_sql' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/sc hema_statements.rb:92:increate_table’
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/mysql_adapt
er.rb:283:in
create_table' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/migration.rb:170:insend’
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/migration.rb:170:in
method_mis sing' ./db/migrate//001_init.rb:4:inup’
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/migration.rb:228:in
send' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/migration.rb:228:inmigrate’
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/migration.rb:223:in
each' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/migration.rb:223:inmigrate’
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/migration.rb:190:in
up' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/migration.rb:181:inmigrate’
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/tasks/databases.rake:3
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/tasks/databases.rake:2:in
call' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:232:inexecute’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:232:in each' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:232:inexecute’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:202:in invoke' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:195:insynchronize’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:195:in invoke' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:1719:inrun’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:1719:in each' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:1719:inrun’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.0/bin/rake:7
c:/ruby/bin/rake:18:in `load’
c:/ruby/bin/rake:18

this line “data” causes the error:

create_table "article_images", :force => true do |t|
  t.column "article_id", :integer, :limit => 10, :default => 0
  t.column "data", :binary, :default => "", :null => false
  t.column "content_type", :string, :limit => 45, :default => "", 

:null
=> false
t.column “position”, :integer, :limit => 10, :default => 0
t.column “updated_at”, :timestamp
t.column “shop_id”, :integer, :limit => 10, :default => 0, :null
=>
false
end

i am migrating towards mysql 5.0.18.

is it a known bug of rails?

Regards
Peter

Peter E. wrote:
[snip]

rake aborted!
undefined method `string_to_binary’ for
ActiveRecord::ConnectionAdapters::ColumnDefinition:Class
[snip]
this line “data” causes the error:

create_table "article_images", :force => true do |t|
  t.column "article_id", :integer, :limit => 10, :default => 0
  t.column "data", :binary, :default => "", :null => false
  t.column "content_type", :string, :limit => 45, :default => "", 

:null
=> false
t.column “position”, :integer, :limit => 10, :default => 0
t.column “updated_at”, :timestamp
t.column “shop_id”, :integer, :limit => 10, :default => 0, :null
=>
false
end

i am migrating towards mysql 5.0.18.

is it a known bug of rails?
I don’t know if there is a bug filed on it or not. It has certainly
been mentioned on the list before. There are two things to note:

  1. The data column has been output (most likely by the schema dumper)
    as a binary column with a :default => “”. This of course makes no
    sense. Remove the default clause and the error will probably go away.
    Of course, the unfortunate thing about this is that you can’t rely on
    schema.rb (re-generated on every migration step) as a reliable
    representation of your schema.

  2. The string_to_binary method is present on the Column class, but not
    the ColumnDefinition class in Rails 1.0. Based on a reading of the code
    it looks like the correct place is in the Column class, however in
    schema_statements.rb a ColumnDefinition object may be returned from the
    column() method. That object does not have a string_to_binary method.
    Some folks on the list have solved this problem by adding this to the
    ColumnDefinition class (although this is just a hack).

    Used to convert from Strings to BLOBs

    def self.string_to_binary(value)
    value
    end

-damon