Okay, so it seems I should do a change_column after the rename. Sorry
for the waste of bytes and I was expecting Rails to do everything for
me with one line of code :)
class RenameRecentLocationId < ActiveRecord::Migration
def self.up
rename_column :devices, :recent_location_id, :recent_reading_id
change_column :devices, :recent_reading_id, :integer, :default =>
0
end
def self.down
rename_column :devices, :recent_reading_id, :recent_location_id
change_column :devices, :recent_location_id, :integer, :default =>
0
end
end
On Jun 22, 11:03 am, dennis baldwin
<dennisbald...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi,
>
> I''m wondering if anyone has experienced problems with losing
default
> column values when running a migration. I have a column that defaults
> to a value of 0, yet when I run a migration I lose the default value
> which reverts to NULL. My migration is simple:
>
> class RenameRecentLocationId < ActiveRecord::Migration
> def self.up
> rename_column :devices, :recent_location_id, :recent_reading_id
> end
>
> def self.down
> rename_column :devices, :recent_reading_id, :recent_location_id
> end
> end
>
> Am I missing something or is this a known issue? Thanks in advance
> for any light you can shed on the problem.
>
> Best regards,
> Dennis
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---