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 => "<i>No Qualifications</i>" add_column :users, :subject, :string, :default => "<i>No Subject</ i>" add_column :users, :about_me, :text, :default => "<i>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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 13 Apr 2008, at 16:20, Prateek wrote:> > 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) - > > =================================================> > 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?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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Works! Thanks a lot Fred. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---