2016-12-24 18 views
3

我想在MySQL数据库中添加一个JSON列:如何通过运行在MySQL中添加一个JSON列使用Rails 5迁移

class AddStatisticsToPlayerStatistic < ActiveRecord::Migration[5.0] 
    def change 
     add_column :player_statistics, :statistics, :json 
    end 
end 

但我发现了这个错误,当我尝试运行耙db:migrate

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 `player_statistics` ADD `statistics` json 

有没有人知道如何在MySQL Ver 14.14 Distrib 5.5.53中添加JSON列。正常吗?

在此先感谢!

+1

的MySQL 5.5 ...从文档JSON本地数据类型从5.7开始 - [JSON(HTTPS://dev.mysql。 com/doc/refman/5.7/en/json.html) – Mat

+0

我太盲目了,我已经更新到MySQL 5.7并且工作正常。 – Antonio682

+0

感谢您的帮助! – Antonio682

回答

3

MySQL的文档称,原生JSON数据类型从5.7.8开始 - json

+1

当我升级我的MySQL服务器时,这个sintaxis工作得很完美。 – Antonio682

相关问题