In a Rails Migration, specifying a column as binary generates a blob column. Blob columns, unfortunately, are allocated differently than any other MySQL column type; specifically, they aren’t supported in memory engine-backed tables.

Varbinary columns, on the other hand, are supported. In order to provide varbinary columns in a Migration, I wrote up this simple core extension.

# Specify :varbinary => true in column creation
# No support yet for altering tables to varbinary

One Comment

  1. Alexis

    In ActiveRecord 3.2.21, you can overwrite blob defined in lib/active_record/connection_adapters/abstract_mysql_adapter.rb by varbinary:

    ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter::NATIVE_DATABASE_TYPES[:binary][:name] = “varbinary”

Leave a Comment

Enclose code in <code lang="ruby"></code> if you care.
Preview your comment using the button below.