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!
JSON support was introduced in MySQL 5.7. 8. In addition to the benefits just listed, having JSON as a native type in MySQL means that the database can automatically validate JSON documents stored in JSON columns. Invalid documents produce an error.
Yes, however, Domo's MySQL 5.6 environment predates JSON parsing support which was introduced in MySQL 5.7 and expanded in MySQL8. 0+.
MySQL supports a native JSON data type defined by RFC 7159 that enables efficient access to data in JSON (JavaScript Object Notation) documents. The JSON data type provides these advantages over storing JSON-format strings in a string column: Automatic validation of JSON documents stored in JSON columns.
MySQL docs says that JSON native data type starts from 5.7.8 - json
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With