Support evolving unique_together.

Review Request #5098 — Created Dec. 12, 2013 and submitted

Information

Django Evolution
master

Reviewers

Support evolving unique_together.

Django-Evolution has always recorded unique_together, but never
supported evolving it. If a project changed this value, it would be
ignored and never applied to the database, yet would be recorded.

This introduces a new ChangeMeta mutation that accepts changing a Meta
property. Currently, only unique_together is supported. The
unique_together property can be set to any value, and Django Evolution
will attempt to drop any old indexes it can find (if any exist) from the
old signature, and set up indexes for the new signature.

Projects should add a ChangeMeta for any models that have a
unique_together, to ensure that the proper value is used and recorded.

  • Unit tests pass for SQLite, MySQL, and Postgres, with Django 1.4 and 1.5.

  • Installed a Review Board 1.6.x site with Django Evolution 0.6.9 using MySQL.
    Then, with RB 2.0 and this patch, I checked evolve --hint. It listed evolutions
    for all the unique_together fields.

  • Added those evolution files and ran evolve --execute. Saw that they applied.

  • Also tested all this with my old database that I've carried over since 1.0 (and
    had newly stored unique_together fields but no actual indexes for them). No
    problems.

Description From Last Updated

Should this be __repr__ instead?

daviddavid
david
  1. So I admit my knowledge of all of this is pretty limited, so I'm relying on your testing a lot.

    1. I'll admit, every change I do scares me, but I think this one works from my testing.

      With one exception, which I'll be working on tonight... Not a breakage, just if you have a stored unique_together that doesn't actually have matching entries in the database, and we add a ChangeMeta with that same unique_together (in an effort to fix up the database), it currently does nothing. I'd like it to add them to the database if missing. That can be a separate change though.

  2. django_evolution/mutations.py (Diff revision 1)
     
     
    Show all issues

    Should this be __repr__ instead?

    1. One may opt to go that route, but all the other ones use __str__, so I'm staying consistent. These are actually used to generate the hinted evolution.

  3. 
      
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed