I have one PostgreSQL table which I want to transform to MySql in my Rails app. Main thing is that gateways column won't transform into an 'array' column. It looks like this in schema.rb:
create_table "settings", force: :cascade do |t|
t.integer "gateways", default: [], array: true
t.integer "name"
t.integer "lastname"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
When I run this migration(after installing MySql gem):
class CreateSettings < ActiveRecord::Migration[5.2]
def change
create_table :settings do |t|
t.integer gateways, array: true, default: []
t.string :name
t.string :lastname
t.timestamps
end
end
end
I got, in my schema.rb, table which hasn't default: [] and array: true values:
create_table "settings", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.integer "gateways"
t.integer "name"
t.integer "lastname"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
And if I want to add values for gateways in console:
>Setting.first.gateways = [1,2,3]
I always get nil as a result
>Setting.first.gateways
>nil
I tried also with serialize :gateways in my Setting.rb model but that also don't work
Any ideas?
Edit: It's not same as this question because it is an explanation for PostgreSQL database, not MySql