Add knowledge of Django Migrations and tracking of the schema upgrade method.

Review Request #10550 — Created May 13, 2019 and updated

chipx86
Django Evolution
master
a8e94ba...
django-evolution

One of the major pillars of Django Evolution 1.0 is compatibility with
Django's built-in schema migrations. Apps that use Migrations need to
not be tracked for evolutions, and legacy apps using evolutions need to
be able to transition to migrations.

This change adds the beginnings of the Migrations support. It introduces
a concept of an upgrade method (evolutions, migrations, or
undetermined), which can be computed from an app based on the presence
of evolutions or migrations submodules and whether an evolution
transitions the app to migrations.

Transitioning is done through a new MoveToDjangoMigrations mutation.
Once applied to an app, further evolutions are no longer allowed on that
app, only migrations. This allows a starting migration to be specified,
defaulting to the standard "0001_initial" used by migrations. This
is intended for theoretical specialized cases where an app may have
supported both migrations and evolutions, resulting in a common branch
point for further migrations. It's also intended for future work that
could allow an app to transition back to evolutions and then back to
migrations. Basically, future expansion.

This upgrade method is stored in the signature and included in diffs.
Apps that appear to have gone from evolutions to migrations will be
shown in hints. The signature also tracks the last migration ID applied
to an app using migrations. Currently, that's always going to be None,
but this will be used later when the evolver is ready to manage
migrations.

Unit tests pass for Django 1.6 and 1.11 and on Python 2.7 and 3.7.

Tested locally with an attempted upgrade simulation from Review Board
3.0 to 4.0 on Django 1.11. This included a mix of apps using evolutions
to upgrade, apps using migrations, and apps that were using evolutions
but move to migrations using MoveToDjangoMigrations. Saw the simulation
results I expected.

Description From Last Updated

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E722 do not use bare except'

reviewbotreviewbot

Migrations shouldn't be capitalized here.

daviddavid

Migrations shouldn't be capitalized here.

daviddavid

Migrations shouldn't be capitalized here.

daviddavid

Migrations shouldn't be capitalized here.

daviddavid

Hmm. Shouldn't this say can't be resolved by evolutions?

daviddavid

Migrations shouldn't be capitalized here.

daviddavid

And here.

daviddavid

And here.

daviddavid
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

chipx86
david
  1. This looks quite good. Most of my comments here regard the capitalization of "migrations", which is inconsistent throughout. Django's docs don't capitalize it, so I don't think we should (except of course where it's sentence capitalized).

  2. django_evolution/mutations.py (Diff revision 2)
     
     

    Migrations shouldn't be capitalized here.

  3. django_evolution/mutations.py (Diff revision 2)
     
     

    Migrations shouldn't be capitalized here.

  4. django_evolution/mutations.py (Diff revision 2)
     
     

    Migrations shouldn't be capitalized here.

  5. django_evolution/signature.py (Diff revision 2)
     
     

    Migrations shouldn't be capitalized here.

  6. django_evolution/signature.py (Diff revision 2)
     
     

    Hmm. Shouldn't this say can't be resolved by evolutions?

  7. django_evolution/utils/evolutions.py (Diff revision 2)
     
     

    Migrations shouldn't be capitalized here.

  8. django_evolution/utils/evolutions.py (Diff revision 2)
     
     

    And here.

  9. django_evolution/utils/evolutions.py (Diff revision 2)
     
     

    And here.

  10. 
      
chipx86
Review request changed

Change Summary:

Changed capitalization of "Migrations" to just "migrations".

Commit:

-23f71545e966ba9ff1004abefea4c9be63c49ab8
+a8e94ba5f4ab9ee5d59186ed42271e0c93620bbb

Diff:

Revision 3 (+811 -54)

Show changes

Checks run (2 succeeded)

flake8 passed.
JSHint passed.
david
  1. Ship It!
  2. 
      
Loading...