Remove default value from column on migration

I need to remove a default value on a PostgreSQL database column in a
Rails migration.

The table contains a column which is a string with :null =>
true, :default => nil. I need to migrate to :null => false, but the
end result in the database's DDL has a default value of "NULL" (a
string). How could I get rid of this?

I have looked at change_column_default which didn't get me too far.
I'm looking for something along the lines of
"remove_column_default :the_table, :the_column". Is this possible?

Thanks,

-Harold

Lake, thanks for your answer. However, my migration does exactly this
(change_column). The problem is that I do not want a default value on
the resulting column.

To continue with the example you provided, if I do:

change_column :books, :name, :string, :default => "Lake"

I am making the default for the column be "Lake", which is not the
intended result. Ideally, I would simply say:

change_column :books, :name, :string, :null => false

In which case the name column in the books table is not nullable (this
is what I want). My original column was nullable, and had a default
value of NULL, but when this migration is ran, the resulting column
has a default value of "NULL" as a string, which is what I want to
avoid...

If I try

change_column :books, :name, :string, :null => false, :default => nil

I end up with the same result (default value of "NULL").

How can I get rid of the default value for this table all together?

One possible solution is to do:

add_column :books, :temp_name, :string, :null =3D> false
#store names on new temp_name column
Book.find(:all).each do |b|
  b.name.nil? b.temp_name => b.name : b.temp_name = 'Unknown'
  b.save!
end
remove_column :books, :name
rename_column :books, :temp_name, :name

I'm wondering if there is an easier way though...

Thanks again,

-H

PS: What happened to this group for the better part of the day? It was
inaccessible for a while...