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 -- -------------------------------------------------------------------- I am Mark Daggett and I approve this message.
On 9.1.2006, at 8.35, M Daggett wrote:> 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?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 [2] http://dev.rubyonrails.org/ticket/3212> > Thanks, > Mark > > -- > -------------------------------------------------------------------- > I am Mark Daggett and I approve this message. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Jarkko Laine http://jlaine.net http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2363 bytes Desc: not available Url : http://wrath.rubyonrails.org/pipermail/rails/attachments/20060109/e72a8be6/smime.bin
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 Laine <jarkko@jlaine.net> wrote:> > On 9.1.2006, at 8.35, M Daggett wrote: > > > 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? > > 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 > [2] http://dev.rubyonrails.org/ticket/3212 > > > > > > Thanks, > > Mark > > > > -- > > -------------------------------------------------------------------- > > I am Mark Daggett and I approve this message. > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > -- > Jarkko Laine > http://jlaine.net > http://odesign.fi > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >-- -------------------------------------------------------------------- I am Mark Daggett and I approve this message.
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 <heavysixer@gmail.com> wrote:> 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 Laine <jarkko@jlaine.net> wrote:
> >
> > On 9.1.2006, at 8.35, M Daggett wrote:
> >
> > > 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?
> >
> > 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
> > [2] http://dev.rubyonrails.org/ticket/3212
> >
> >
> > >
> > > Thanks,
> > > Mark
> > >
> > > --
> > >
--------------------------------------------------------------------
> > > I am Mark Daggett and I approve this message.
> > > _______________________________________________
> > > Rails mailing list
> > > Rails@lists.rubyonrails.org
> > > http://lists.rubyonrails.org/mailman/listinfo/rails
> > >
> >
> > --
> > Jarkko Laine
> > http://jlaine.net
> > http://odesign.fi
> >
> >
> >
> > _______________________________________________
> > Rails mailing list
> > Rails@lists.rubyonrails.org
> > http://lists.rubyonrails.org/mailman/listinfo/rails
> >
> >
> >
> >
>
>
> --
> --------------------------------------------------------------------
> I am Mark Daggett and I approve this message.
>
--
--------------------------------------------------------------------
I am Mark Daggett and I approve this message.