Is there a way to tell db:migrate to continue if it encounters an exception? Sometimes during developing, the migration files aren''t always exactly the way I want them (surprisingly;-). For example: 001_add_table1.rb: class AddTable1 < ActiveRecord::Migration def self.up create_table "table1", :force => true do |t| t.column :string1, :string, :limit => 40, :null => false end end def self.down drop_table :table1 end end 002_add_column.rb: class AddColumn < ActiveRecord::Migration def self.up add_column :table1, :text1, :text, :null => false end def self.down remove_column :table1, :text1 end end Somewhere along the line I may end up deleting table ''table1'' from the database inadvertently. So, if I run db:migrate, it''s quite likely to choke when applying version 2 (002_add_column.rb) or attempting a rollback to version 1. But during development, I want it to keep going. Is there a way to do that? Thanks, Stan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 1/25/07, stan.baptista <stan.baptista-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Is there a way to tell db:migrate to continue if it encounters an > exception? Sometimes during developing, the migration files aren''t > always exactly the way I want them (surprisingly;-). > > For example: > > 001_add_table1.rb: > > class AddTable1 < ActiveRecord::Migration > def self.up > create_table "table1", :force => true do |t| > t.column :string1, :string, :limit => 40, :null => false > end > end > > def self.down > drop_table :table1 > end > end > > 002_add_column.rb: > > class AddColumn < ActiveRecord::Migration > def self.up > add_column :table1, :text1, :text, :null => false > end > > def self.down > remove_column :table1, :text1 > end > end > > Somewhere along the line I may end up deleting table ''table1'' from the > database inadvertently. So, if I run db:migrate, it''s quite likely to > choke when applying version 2 (002_add_column.rb) or attempting a > rollback to version 1. > > But during development, I want it to keep going. Is there a way to do > that? > > Thanks, > StanUsually deleting a table would be done as a migration too. But, if you want migrations, and well, any ruby code, to continue on exceptions, look into the use of begin/rescue. -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> But, if you want migrations, and well, any ruby code, to continue on > exceptions, look into the use of begin/rescue.Got it. Thanks --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---