2

I have created Rails(3.2) application with mysql(5.7.16) backend. I can't add json type column when creating table but I can able to add json column by new migration. I have used following code in create table migration, What was wrong here ?

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

      t.timestamps
    end
  end
end
1
  • 1
    Does your code return any error message? If yes, pls share it with us. Commented Dec 28, 2016 at 13:59

1 Answer 1

3

You should be able to create JSON column type. Probably you run in couple of errors. In case there is a error after migration try first reverting it:

rake db:migrate:down VERSION=<version>

Than you can try like this:

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.