你如何让 Rails 使用 mysql 中的 LONGBLOB 列? [英] How do you get Rails to use the LONGBLOB column in mysql?
本文介绍了你如何让 Rails 使用 mysql 中的 LONGBLOB 列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试编写将 LONGBLOB 列添加到 MySQL 数据库中的表的迁移.我想使用 LONGBLOB 而不是 BLOB 以便我可以在二进制列中存储更多数据.问题是即使我指定了更大的大小,它也会添加一个 BLOB 列.
I'm trying to write a migration that adds a LONGBLOB column to a table in a MySQL database. I'd like to use LONGBLOB instead of BLOB so that I can store more data in the binary column. The problem is that it adds a BLOB column even though I specify a larger size.
这是我用来添加列的行:
Here's the line I'm using to add the column:
add_column :db_files, :data, :binary, :null => false, :size => 1.megabyte
我做错了吗?
推荐答案
以下将创建一个 MEDIUMBLOB 字段.使用 16.megabyte 转到 LONGBLOB.
The following will create a MEDIUMBLOB field. Use 16.megabyte to go to a LONGBLOB.
def self.up
create_table "blob_test", :force => true do |t|
t.column :data, :binary, :limit => 10.megabyte
end
end
这篇关于你如何让 Rails 使用 mysql 中的 LONGBLOB 列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文