Rails: Adding migration to add an array (default empty)

Rails 4 the PostgreSQL Array data type

In terminal

$ rails generate migration AddTagsToProduct tags:string

Migration file:

class AddTagsToProduct < ActiveRecord::Migration
  def change
    add_column :products, :tags, :string, array: true, default: []
  end
end

https://coderwall.com/p/sud9ja/rails-4-the-postgresql-array-data-type

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)