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

Thanks for the quick reply , Cant I ignore errors only like if a column
is already present then move ahead, If a table is already present move
ahead.

Not ignoring all the errors.

Thanks & Regards
Saurabh

Steve R. wrote:

On Aug 13, 2009, at 5:11 PM, Saurabh A. wrote:

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.

On Aug 13, 2009, at 5:11 PM, Saurabh A. wrote:

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?

On Aug 13, 5:21 pm, Saurabh A. [email protected]

Actually I am not sure whats happenning I am using redmine and
installing plugins for that , Sometimes it seems that migration executes
( ie column and table ) get created but there is no entry in schema
table creating the issue.

SO I was trying to get over those issues.

Thanks & Regards
Saurabh

hitch wrote:

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?

On Aug 13, 5:21�pm, Saurabh A. [email protected]

Saurabh A. 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