# Rails ignoring the migration file

**URL:** <https://www.ruby-forum.com/t/rails-ignoring-the-migration-file/60435>\
**Category:** Rails\
**Created:** [January 9, 2006, 7:36am UTC](https://www.ruby-forum.com/t/rails-ignoring-the-migration-file/60435 "2006-01-09T07:36:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![M\_Daggett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/76d3ee/32.png) [@M\_Daggett](https://www.ruby-forum.com/u/M_Daggett)\
**Post date:** [January 9, 2006, 7:36am UTC](https://www.ruby-forum.com/t/rails-ignoring-the-migration-file/60435/1 "2006-01-09T07:36:12Z")

</div>

I have a mysql database that I am trying to use migrations on. The  
problem that I am having is that when I create a blob field in my  
migration file like so:

t.column “data”, :binary, :limit =\> 15.megabytes, :null =\> false

rails changes it to this in the schema:

t.column “data”, :binary, :default =\> “”, :null =\> false

not only is this not what I wanted because it removes the size  
restrictions it also blows up when you try to do rake db\_import\_schema  
with this error:

site\_path\>rake db\_schema\_import  
(in D:/sites/itsthes/itsthes-ruby/itsthes)  
rake aborted!  
undefined method `string\_to\_binary’ for  
ActiveRecord::ConnectionAdapters::ColumnDefinition:Class

Is anyone else know why this is happening? Does anyone else have a  
problem with rails converting values in the schema.rb to something  
other than what is in the migration file?

Thanks,  
Mark

–

---

<div class="post-metadata">

**Author:** ![M\_Daggett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/76d3ee/32.png) [@M\_Daggett](https://www.ruby-forum.com/u/M_Daggett)\
**Post date:** [January 9, 2006, 9:30pm UTC](https://www.ruby-forum.com/t/rails-ignoring-the-migration-file/60435/2 "2006-01-09T21:30:09Z")

</div>

Thanks Jarkko,  
I was noticing that too when I went to call through the codebase  
looking for the method. I was able to get around my problem by loading  
my binary requirements into a later migration file, which overwrote  
the schema.rb

On 1/9/06, Jarkko L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > ActiveRecord::ConnectionAdapters::ColumnDefinition:Class  
> > not in ColumnDefinition where it should be. This is a reported bug  
> > Thanks,
> 
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–

---

<div class="post-metadata">

**Author:** ![M\_Daggett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/76d3ee/32.png) [@M\_Daggett](https://www.ruby-forum.com/u/M_Daggett)\
**Post date:** [January 9, 2006, 12:44pm UTC](https://www.ruby-forum.com/t/rails-ignoring-the-migration-file/60435/3 "2006-01-09T12:44:25Z")

</div>

On 9.1.2006, at 8.35, M Daggett wrote:

> not only is this not what I wanted because it removes the size  
> Is anyone else know why this is happening? Does anyone else have a  
> problem with rails converting values in the schema.rb to something  
> other than what is in the migration file?

Mark,

I don’t know about the changing schema definition but I know why your  
migration fails. string\_to\_binary is for some reason in Column class,  
not in ColumnDefinition where it should be. This is a reported bug  
(see [1] and [2]). I’m preparing a patch with failing tests at the  
moment, will post it tonight.

//jarkko

[1] [http://dev.rubyonrails.org/ticket/3101](http://dev.rubyonrails.org/ticket/3101)  
[2] [http://dev.rubyonrails.org/ticket/3212](http://dev.rubyonrails.org/ticket/3212)

---

<div class="post-metadata">

**Author:** ![M\_Daggett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/76d3ee/32.png) [@M\_Daggett](https://www.ruby-forum.com/u/M_Daggett)\
**Post date:** [January 9, 2006, 10:15pm UTC](https://www.ruby-forum.com/t/rails-ignoring-the-migration-file/60435/4 "2006-01-09T22:15:42Z")

</div>

I know this is probably a bad thing to do, but I modified the  
ColumnDefinition class inside schema\_definitions.rb to include the  
self.string\_to\_binary method like so:

class ColumnDefinition \< Struct.new(:base, :name, :type, :limit,  
:default, :null) #:nodoc:  
def to\_sql  
column\_sql = “#{base.quote\_column\_name(name)}  
#{type\_to\_sql(type.to\_sym, limit)}”  
add\_column\_options!(column\_sql, :null =\> null, :default =\>  
default)  
column\_sql  
end

```
  # added to fix missing method error when running rake tests
  # Used to convert from Strings to BLOBs
  def self.string_to_binary(value)
    value
  end

```

It appears to be working now for both unit testing and migrations…  
though I may have broken something else I have not found yet!

Mark

On 1/9/06, M Daggett [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > On 9.1.2006, at 8.35, M Daggett wrote:
> > 
> > > 
> > 
> > moment, will post it tonight.
> > 
> > > 
> > 
> > Jarkko L.
> 
> ## –
> 
> I am Mark Daggett and I approve this message.

–
