04 Jan, 2007

Published at 04:40PM

Tagged with problems, rails, and programming

This post has 2 comments

Rails migration problem

Maybe this isn’t a migration problem, but I’m looking for a solution from within the migration file. I believe it’s a MySQL problem, in the event that you try to set a default value to a column of type :text. It doesn’t allow this, which in turn, halts the migration. Here’s what I have:

1
2
3
4
5
6
7
8
9
10
11
class TextLengthUpdate < ActiveRecord::Migration
  self.up
    # change_column, :tablename, :field_name, :datatype, :options
    change_column :comments, :body, :text
    ...
  end

  self.down
    ...
  end
end

When it returns the MySQL error, it shows that it’s trying to specify a DEFAULT '', which is why it’s breaking. How can I tell the migration to not set a default? Any thoughts?

Comments

Chris Thursday, 04 Jan, 2007 Posted at 05:11PM

Check this out: Rails ticket #6695

Sounds like a Rails bug.

Ryan Thursday, 04 Jan, 2007 Posted at 05:27PM

That explains it. Thanks…

Do you have something to say about this post?
Retype the image to the right Spam Hint: Are You Human? Textile Formatting Tips

or

Ryan Heath | Site Management A Ruby on Rails production.

This site is a Formed Function. Formed Function LLC | @formedfunction | Get in Touch