On 04 Jul 2008, at 09:36, Vapor .. wrote:
> I have already created a migration. It adds 5 columns. Now I edit
> migration file and enter 2 more column.
>
> How can I remigrate so that 2 new columns would be added without
> loosing
> data with db:migrate:reset?
By putting it in a new migration file instead of adding it to an
already deployed one.
script/generate migration AddTwoMoreColumns
and then in the migration (assuming you are using Rails 2.1):
class AddTimeZoneToUser < ActiveRecord::Migration
def self.up
change_table :users do |t|
t.string :time_zone
t.belongs_to :role
end
end
def self.down
change_table :users do |t|
t.remove :time_zone
t.remove_belongs_to :role
end
end
end
(example taken from:
http://www.akitaonrails.com/2008/5/25/rolling-with-rails-2-1-the-first-full-tutorial-part-1)
Time to go pick up a book and start reading about how to use Rails.
The Rails Way would be a good start.
Best regards
Peter De Berdt
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---