Migrations - add_column :default=>true, :null=>false

Joe Ruby MUDCRAP-CE wrote the following on 15.10.2006 22:12 :

This seems pretty brain dead:

add_column :types, :notify_on_create, :boolean, {:default=>true, :null=>false}

$ rake migrate

Error: ERROR: column "notify_on_create" contains null values : ALTER TABLE types ALTER notify_on_create SET NOT NULL

Why doesn't Rails set the new column to true, as it's supposed to default to? I tried :default=>1 as well (same results).

Is there a way to make this migration work?

Joe

Do you use PostgreSQL by any chance?

Try to load this in your environment.rb:

# add_column in the original PostgreSQLAdapter # begins by creating the column and then adds constraints # which simply doesn't work... AbstractAdapter is ok -> super works class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter     def add_column(table_name, column_name, type, options = {})         super     end end

Lionel