Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails with mysql "Unknown type 'json' for column 'special_info'"

I have created Rails(3.2) application with mysql(5.7.16) database. I have used json column in some tables and it's working fine. But I can see some commented code like following in my schema.rb file

# Could not dump table "shopping_cart_precheckout_details" because of following StandardError
# Unknown type 'json' for column 'special_info'

Migration

class CreateShoppingCartItemSpecialInfos < ActiveRecord::Migration
  def change
    create_table :shopping_cart_item_special_infos do |t|
      t.integer :shopping_cart_checkout_option_id
      t.column :special_info, :json

      t.timestamps
    end
  end
end

Is this affect the production environment and why this commented code added in schema.rb file ?

like image 944
Premanandh Selvakumarasamy Avatar asked Dec 30 '16 06:12

Premanandh Selvakumarasamy


1 Answers

Native support for native JSON column types in Mysql is only available from Rails 5 onwards: https://github.com/rails/rails/pull/21110

For Rails 4, json_on_rails may be considered: https://github.com/saveriomiroddi/json_on_rails

like image 117
prusswan Avatar answered Oct 13 '22 00:10

prusswan