Saurabh Agarwal
2009-Aug-14 00:11 UTC
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 -- Posted via http://www.ruby-forum.com/.
s.ross
2009-Aug-14 00:16 UTC
Re: how to ignore errors in migration - Suppose a column exist
On Aug 13, 2009, at 5:11 PM, 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 > --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.
Saurabh Agarwal
2009-Aug-14 00:21 UTC
Re: how to ignore errors in migration - Suppose a column exist
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 Ross wrote:> On Aug 13, 2009, at 5:11 PM, Saurabh Agarwal 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.-- Posted via http://www.ruby-forum.com/.
hitch
2009-Aug-14 06:28 UTC
Re: how to ignore errors in migration - Suppose a column exist
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 Agarwal <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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 Ross wrote: > > On Aug 13, 2009, at 5:11 PM, Saurabh Agarwal 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. > > -- > Posted viahttp://www.ruby-forum.com/.
Saurabh Agarwal
2009-Aug-14 06:33 UTC
Re: how to ignore errors in migration - Suppose a column exist
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 Agarwal <rails-mailing-l...@andreas-s.net>-- Posted via http://www.ruby-forum.com/.
Sniper Abandon
2009-Aug-14 10:26 UTC
Re: how to ignore errors in migration - Suppose a column exist
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 > Saurabhcreate_table "users",:force=>true do |t| t.string :name blah blah ..... end don''t use exception handler for migrations -- Posted via http://www.ruby-forum.com/.