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.

On Jun 17, 10:13 pm, “stephen O’D” [email protected] wrote:

  t.column :description, :string

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!

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…