I am using Rails 2.1 and mysql. I have a very simple migration: class CreateTasks < ActiveRecord::Migration def self.up create_table :tasks do |t| t.column :job_id, :integer, :null => false t.column :name, :string, :null => false t.column :description, :string t.column :actual, :number, :null => true end end def self.down drop_table :tasks end end When I run this, the SQL that is generated is broken: CREATE TABLE `tasks` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `name` varchar(255) NOT NULL, `description` varchar(255) DEFAULT NULL NULL, `actual` number DEFAULT NULL NULL) ENGINE=InnoDB Note the DEFAULT NULL NULL, after the description and actual columns - and also the default NULL after the id column which I don''t think should be there either - am I doing something totally stupid, or is something broken here? I have used migrations successfully on Rails 1.x and 2.0 on this machine before OS X Tiger. --~--~---------~--~----~------------~-------~--~----~ 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 Jun 17, 10:13 pm, "stephen O''D" <stephen.odonn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am using Rails 2.1 and mysql. > > I have a very simple migration: > > class CreateTasks < ActiveRecord::Migration > > def self.up > create_table :tasks do |t| > t.column :job_id, :integer, :null => false > t.column :name, :string, :null => false > t.column :description, :string > t.column :actual, :number, :null => true > end > end > > def self.down > drop_table :tasks > end > end > > When I run this, the SQL that is generated is broken: > > CREATE TABLE `tasks` (`id` int(11) DEFAULT NULL auto_increment PRIMARY > KEY, `name` varchar(255) NOT NULL, `description` varchar(255) DEFAULT > NULL NULL, `actual` number DEFAULT NULL NULL) ENGINE=InnoDB > > Note the DEFAULT NULL NULL, after the description and actual columns > - and also the default NULL after the id column which I don''t think > should be there either - am I doing something totally stupid, or is > something broken here? > > I have used migrations successfully on Rails 1.x and 2.0 on this > machine before OS X Tiger.Seems I was doing something stupid - :number is not a correct column type - changing it to :decimal sorts the problem. Definitely a strange error though! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Well, the new sexyosity is that you say instead: t.integer :job_id, :null => false So--you call a method named after the datatype on the table block var, the first arg is the field name & other args get tacked on afterwards. That said, I would have expected the older style to be supported still--and judging from the sql there it looks like it''s trying. Dunno. Someone here will tho, I don''t doubt... -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of stephen O''D Sent: Tuesday, June 17, 2008 2:14 PM To: Ruby on Rails: Talk Subject: [Rails] Rails 2.1 migrations default value problem I am using Rails 2.1 and mysql. I have a very simple migration: class CreateTasks < ActiveRecord::Migration def self.up create_table :tasks do |t| t.column :job_id, :integer, :null => false t.column :name, :string, :null => false t.column :description, :string t.column :actual, :number, :null => true end end def self.down drop_table :tasks end end When I run this, the SQL that is generated is broken: CREATE TABLE `tasks` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `name` varchar(255) NOT NULL, `description` varchar(255) DEFAULT NULL NULL, `actual` number DEFAULT NULL NULL) ENGINE=InnoDB Note the DEFAULT NULL NULL, after the description and actual columns - and also the default NULL after the id column which I don''t think should be there either - am I doing something totally stupid, or is something broken here? I have used migrations successfully on Rails 1.x and 2.0 on this machine before OS X Tiger. --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---