How do I add a binary type column with limit option to a MySQL database
with migrations?
Here''s what I have for a migration right now:
1. def self.up
2. add_column :table_name, :column_name, :binary, :limit =>
1.megabyte
3. end
Then I ''rake db:migrate'':
1. -- add_column(:table_name, :column_name, :binary,
{:limit=>1048576})
2. -> 0.0165s
When I check the schema:
1. t.column "column_name", :binary
Without a limit option! And even though it appears to migrate, the limit
in the application definitely does not change.
Can anyone tell me what to do differently? Thanks.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On Jul 24, 1:09 pm, Patrick Berkeley <rails-mailing-l...@andreas- s.net> wrote:> How do I add a binary type column with limit option to a MySQL database > with migrations?<snip />> Without a limit option! And even though it appears to migrate, the limit > in the application definitely does not change.I use the limit option, and although it does not appear in my schema file, it does change the size of the binary column. I haven''t tested to see if it creates an upper bound, but it does change the BLOB type. The four BLOB types are TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB. For example, a :limit=>256.kilobyte creates a MEDIUMBLOB instead of a BLOB (default). If you want an upper bound on length, maybe create a validation in your model? http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M000942 ~Rusty --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rusty Burchfield wrote:> On Jul 24, 1:09 pm, Patrick Berkeley <rails-mailing-l...@andreas- > s.net> wrote: >> How do I add a binary type column with limit option to a MySQL database >> with migrations? > <snip /> >> Without a limit option! And even though it appears to migrate, the limit >> in the application definitely does not change. > > I use the limit option, and although it does not appear in my schema > file, it does change the size of the binary column. I haven''t tested > to see if it creates an upper bound, but it does change the BLOB type. > > The four BLOB types are TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB. > > For example, a :limit=>256.kilobyte creates a MEDIUMBLOB instead of a > BLOB (default). > > If you want an upper bound on length, maybe create a validation in > your model? > http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M000942 > > ~RustyThat''s good info. I had been writing a custom validation to check the length. I''m assuming each step up in BLOB type doubles the size. So, TINYBLOB = 64k, BLOB = 128k, MEDIUMBLOB = 256k, LONGBLOB = 512k. Thanks. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---