Reputation: 91
I am using Rails 4.1.1 and pg (0.17.1) gem I having error while running the migration
ActiveRecord::StatementInvalid: PG::DatatypeMismatch: ERROR: column "page_ids" is of type integer[] but default expression is of type integer
here is my migration code
class CreatePages < ActiveRecord::Migration
def change
create_table :pages do |t|
t.string :name
t.integer :page_ids, array: true, null: false, default: '{}'
t.timestamps
end
end
end
the array: true not working
Upvotes: 1
Views: 810
Reputation: 9523
Try:
t.integer :page_ids, array: true, null: false, default: []
Upvotes: 4