Migrating with loosing data

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?

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:
Rolling with Rails 2.1 - The First Full Tutorial - Part 1 | AkitaOnRails.com)

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