How to add a JSON column in MySQL with Rails 5 Migration

醉酒当歌 提交于 2019-12-07 01:07:42

问题


I'm trying to add a json column in MySQL db by running:

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

But I'm getting this error when I try to run rake 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

Does anyone know how to add a JSON column in MySQL Ver 14.14 Distrib 5.5.53. properly?

Thanks in advance!


回答1:


MySQL docs says that JSON native data type starts from 5.7.8 - json



来源:https://stackoverflow.com/questions/41313166/how-to-add-a-json-column-in-mysql-with-rails-5-migration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!