你如何让Rails在mysql中使用LONGBLOB列?

我正在尝试编写一个将LONGBLOB列添加到MySQL数据库中的表的迁移。 我想使用LONGBLOB而不是BLOB,以便我可以在二进制列中存储更多数据。 问题是它添加了BLOB列,即使我指定了更大的大小。

这是我用来添加列的行:

add_column :db_files, :data, :binary, :null => false, :size => 1.megabyte 

我做错了吗?

以下将创建一个MEDIUMBLOB字段。 使用16.megabyte转到LONGBLOB。

 def self.up create_table "blob_test", :force => true do |t| t.column :data, :binary, :limit => 10.megabyte end end 

class Migration_create_technologe扩展CI_Migration {

 public function up() { $this->dbforge->add_field(array( 'id' => array( 'type' => 'INT', 'constraint' => 11, 'unsigned' => TRUE, 'auto_increment' => TRUE ), 'title' => array( 'type' => 'VARCHAR', 'constraint' => '100', 'collation' => 'utf8_unicode_ci', ), 'writer' => array( 'type' => 'VARCHAR', 'constraint' => '100', 'collation' => 'utf8_unicode_ci', ), 'created' => array( 'type' => 'datetime', 'default'=> '0000-00-00 00:00:00', 'collation' => 'utf8_unicode_ci', ), )); $this->dbforge->add_key('id',TRUE); $this->dbforge->add_field("body longblob NOT NULL "); $this->dbforge->create_table('technologe'); } public function down() { $this->dbforge->drop_table('technologe'); } }