AliZubi
AliZubi

Reputation: 91

ActiveRecord::StatementInvalid: PG::DatatypeMismatch: ERROR: column is of type integer[] but default expression is of type integer Rails 4.1.1

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

Answers (1)

Tamer Shlash
Tamer Shlash

Reputation: 9523

Try:

t.integer    :page_ids,     array: true, null: false, default: []

Upvotes: 4

Related Questions