【发布时间】:2015-09-30 12:37:09
【问题描述】:
我正在关注carrierwave 文档here 将多张图片上传到我的列表模型。 什么时候,我用了命令
rails g migration add_images_to_listings images:json
像这样成功创建迁移 -
class AddImagesToListings < ActiveRecord::Migration
def change
add_column :listings, :images, :json
end
end
但运行 rake db:migrate 会引发 mysql 语法错误
Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'json'
at line 1: ALTER TABLE `listings` ADD `images` json/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:299:in `query'
我怀疑这是因为 mysql 不支持 json 数据类型。有什么解决方法吗?
【问题讨论】:
-
如我所见here,您可以在 PostgreSQL 中使用 JSON 数据类型
标签: mysql ruby-on-rails ruby json carrierwave