small medium large xlarge

11 Feb 2009, 07:29
William Hertling (23 posts)

I started my development of my application using SQLite3. I’m now trying to move to a production server using MySQL. Unfortunately MySQL is choking on the migrations for facebook user ids. As Mike suggest in the book, I’ve gone with a 20 byte integer:

== 20081215194758 AddSireToUser: migrating ==================================== – add_column(:users, :sire, :integer, {:limit=>20})

This is very similar to what Mike has in the book on page 53, where he defined a facebook id as: t.integer :facebook_id, :limit=>20, :null=>false

However, I get this error message when running db:migrate: rake aborted! No integer type has byte size 20

Any suggestions on how to get past this?

Thanks, Will

11 Feb 2009, 20:50
William Hertling (23 posts)

I got around this by patching the mysql adapter according to the blog post I found here:

Essential, the patch changes the way mysql interprets :limit like this:

def type_to_sql(type, limit = nil, precision = nil, scale = nil)
        return super unless type.to_s == 'integer'
        case limit
        when 0..3
        when 4..11
        when 12..20
  You must be logged in to comment