how to ignore errors in migration - Suppose a column exist

Hi ,

I am creating a migration but due to some error after it is ignoring whole migration.

I want that if a column or table is already present ignore it and ove ahead with migration execution.

How can i ignore errors in migration normally column or table exist migration.

Thanks & Regards Saurabh

The whole idea of a migration is that you can build your database from scratch, but if you really want to write migrations that can fail:

begin    # do something rescue    puts "this migration didn't work" end

I don't recommend writing code for migrations that anticipates failure and goes on. You could hose a perfectly good database.

One of the reasons you want to use migrations is to avoid that kind of error. The schema_migrations table automatically keeps track of what migrations have been applied and which have not. You don't want to see errors for duplicate columns or duplicate tables.

Have you been using migrations from the beginning of your project? Or perhaps you are trying to convert to using migrations for a database schema that already exists?

Saurabh Agarwal wrote:

Hi ,

I am creating a migration but due to some error after it is ignoring whole migration.

I want that if a column or table is already present ignore it and ove ahead with migration execution.

How can i ignore errors in migration normally column or table exist migration.

Thanks & Regards Saurabh

create_table "users",:force=>true do |t|    t.string :name    blah blah ..... end

don't use exception handler for migrations