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@googlegroups.com.
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.

Search Discussions

  • Tim Shaffer at Oct 31, 2011 at 7:05 pm
    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@googlegroups.com.
    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.
  • NY at Oct 31, 2011 at 10:05 pm
    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 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@googlegroups.com.
    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 at Oct 31, 2011 at 10:53 pm

    On Oct 31, 6:48 pm, NY 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@googlegroups.com.
    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedOct 31, '11 at 6:48p
activeOct 31, '11 at 10:53p
posts4
users3
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2021 Grokbase