![]() | Dealing with "No integer type has byte size 20" problems with MySQL |
|
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: However, I get this error message when running db:migrate: Any suggestions on how to get past this? Thanks, |
|
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: http://blog.smartlogicsolutions.com/2008/06/24/... 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
"smallint(#{limit})"
when 4..11
"int(#{limit})"
when 12..20
"bigint(#{limit})"
else
'int(11)'
end
end
|
| You must be logged in to comment |

