An array
column is supported by PostgreSQL. Rails will automatically convert a PostgreSQL array to a Ruby array, and vice-versa.
Create a table with an array
column:
create_table :products do |t|
t.string :name
t.text :colors, array: true, default: []
end
Add an array
column to an existing table:
add_column :products, :colors, array: true, default: []
Add an index for an array
column:
add_index :products, :colors, using: 'gin'