I observed this a few times, but not always happen, and if I down the migration and run again, it often works. My migration is really simple like: Foo.find_each do |foo| foo.update_attribute(:bar, "baz") end Occasionally, it reports success, but not actually updated the attribute for the "bar" column of Foo object. It appears to just skip the whole thing and report success. And as I said, if I down it and run again, it has always worked. Anybody else has seen this problem before? I''m using Rails 3.0.10 but I had this problem with older 3.0.x versions as well. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
So whenever you migrate down and back up it works? Sounds like the migration is working properly then. Under what circumstances does it not work? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/DsGRPHenk5cJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
That''s exactly what I try to figure out. Migrations like this randomly get "skipped" (reported success but didn''t do anything). It doesn''t happen consistently (and doesn''t happen most of time). On Oct 31, 12:05 pm, Tim Shaffer <timshaf...-BUHhN+a2lJ4@public.gmane.org> wrote:> So whenever you migrate down and back up it works? Sounds like the > migration is working properly then. > > Under what circumstances does it not work?-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2011-Oct-31 22:53 UTC
Re: Migration reports success but did not do anything
On Oct 31, 6:48 pm, NY <yan....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I observed this a few times, but not always happen, and if I down the > migration and run again, it often works. > > My migration is really simple like: > > Foo.find_each do |foo| > foo.update_attribute(:bar, "baz") > end > > Occasionally, it reports success, but not actually updated the > attribute for the "bar" column of Foo object. It appears to just skip > the whole thing and report success. And as I said, if I down it and > run again, it has always worked. > > Anybody else has seen this problem before? I''m using Rails 3.0.10 but > I had this problem with older 3.0.x versions as well.Failed validations? You do have to be a little careful when using models in migrations. Consider this scenario: - The migration above is written - A new validation is written and a migration that fixes the data already present in the database is written if you try and run both of these migrations in one go then the updates in the first migration fail, because the latest validations are used. if you try and run the migration a second time they succeed because by now the data fixing migration has run. The way to get around this particular problem is to use copies of the model in your migration (the migrations guide on guides.rubyonrails.org discusses this) Fred -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.