Because of server requirements, I'm using MySQL 5.5 in my Rails app.
I would like to use json column type, similar to PostgreSQL, but when I run migration I'm getting error, that json is not supported.
My migration:
def change
add_column :profile_services, :price, :json
end
Can somebody suggest the best solution how to fix this issue?
Since MySQL 5.5 doesn't have JSON data type, in a Rails 4 app, you should use the more database agnostic TEXT type that will work in both MySQL and PostgreSQL.
def change
add_column :profile_services, :price, :text
end
As of MySQL 5.7.8, the JSON column type has been added.
https://dev.mysql.com/doc/refman/5.7/en/json.html
As of Rails 5, MySQL JSON type has been added.
https://github.com/rails/rails/pull/21110
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