Migration Problem

Hello,

I am trying to change the default value of a couple of fields in a
table. In one of my migrations, I had given a default value. It looked
something like this (Please note - ‘users’ table already exists) -

==================================================
[002_add_user_profile.rb] http://pastie.org/179981

class AddUserProfile < ActiveRecord::Migration
def self.up
add_column :users, :age, :integer
add_column :users, :qualification, :text, :default => “No
Qualifications

add_column :users, :subject, :string, :default => “No Subject</
i>”
add_column :users, :about_me, :text, :default => “No About Me</
i>”
end

def self.down
remove_column :users, :age
remove_column :users, :qualification
remove_column :users, :subject
remove_column :users, :about_me
end
end

==================================================

So, to remove the default, I just removed the “:default” from lines
4,5,6, and then I ran ‘rake db:migrate’. But the default it still
there. What should I do to remove it?

Thanks,
Prateek

On 13 Apr 2008, at 16:20, Prateek wrote:

4,5,6, and then I ran ‘rake db:migrate’. But the default it still
there. What should I do to remove it?

You need to migrate down and then back up again with rake db:migrate
VERSION=x
(rails won’t run migration 2 if migration 2 has already been run, even
if you’ve changed the file since).

Fred

Works!
Thanks a lot Fred.