• 
      
    Fish Trophy

    chipx86 got a fish trophy!

    Fish Trophy

    Add smarter support for grabbing the latest Version for a database.

    Review Request #7777 — Created Nov. 23, 2015 and submitted — Latest diff uploaded

    Information

    Django Evolution
    release-0.7.x

    Reviewers

    Historically, django-evolution was using Version.objects.latest() to
    grab the latest version of the database schema. However, this was
    failing in the event that you had two Version entries created within the
    same second on a database that didn't have very good precision on
    date/time fields (MySQL). This easily happened when both computing a
    baseline for new models and then trying to perform very simple and fast
    schema updates.

    We now have a new function, current_version(), which does the same thing
    that latest() did, but with the addition of factoring in the ordering of
    the IDs. In the event that two timestamps match, the newer ID will now
    take precedence, ensuring we're not looking at the "older" baseline
    entry.

    Unit tests pass.

    Simulated the original problem we've seen on a database here. Verified
    the same failure conditions (using an outdated schema, resulting in
    "fields have changed" errors) with the old implementation. Saw the correct
    results with the new one.