iledela
2008-Jan-22 17:43 UTC
MySQL migration: trying to create "not null" boolean column (RoR 2.0)
Hello everyone! Disclaimer: I am really, really new to Rails and this is probably a really stupid question, but I have spent SO LONG trying to find an answer and I''ve gotten nowhere. Thanks in advance for indulging me! I''m trying to set up a boolean column in my database through db/ migrate/001_create_(whatever).rb. Here''s the relevant line: t.boolean :type When I use db:create:all to create the MySQL databases, it makes all columns null, which is a problem for this column. I tried: t.boolean :type, :null => false but that didn''t work and I''m wondering if there''s a different way of doing this in 2.0. Again, really sorry for the simple question but I feel like I''ve looked everywhere! Help much appreciated! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
jonbaty
2008-Jan-22 19:55 UTC
Re: MySQL migration: trying to create "not null" boolean column (RoR 2.0)
db:create:all, should just create your databases (development, test and production). db:migrate should create your (whatever) table from your 001_create_(whatever).rb. i am not sure if this is what you are wanting but try the "default" option... this way your column will always have a value... t.boolean :type, :default => true, :null => false or t.boolean :type, :default => false, :null => false let us know if this does not help... On Jan 22, 11:43 am, iledela <iled...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello everyone! > > Disclaimer: I am really, really new to Rails and this is probably a > really stupid question, but I have spent SO LONG trying to find an > answer and I''ve gotten nowhere. Thanks in advance for indulging me! > > I''m trying to set up a boolean column in my database through db/ > migrate/001_create_(whatever).rb. Here''s the relevant line: > > t.boolean :type > > When I use db:create:all to create the MySQL databases, it makes all > columns null, which is a problem for this column. I tried: > > t.boolean :type, :null => false > > but that didn''t work and I''m wondering if there''s a different way of > doing this in 2.0. Again, really sorry for the simple question but I > feel like I''ve looked everywhere! Help much appreciated!--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---