Add utilities for fetching dependencies for an evolution or its app.
Review Request #11228 — Created Oct. 18, 2020 and submitted
Django Evolution 2.1 is getting support for dependencies defined in
evolutions, allowing a single evolution or all evolutions for an app to
apply before or after other evolutions or migrations. These can be
specified as an app-level dependency (in theevolutions/__init__.py
)
or an evolution-level dependency by setting the following:
BEFORE_EVOLUTIONS
BEFORE_MIGRATIONS
AFTER_EVOLUTIONS
AFTER_MIGRATIONS
Each is a list of items, where each item is either a string containing
an app label (for evolutions) or a tuple containing an app label and
evolution/migration name (for evolutions and migrations).
This change begins adding support for this by introducing utility
functions that will look up these dependencies.
get_evolution_app_dependencies()
will fetch the dependencies specified
at the top-level evolutions/__init__.py
for an app, and
get_evolution_dependencies()
will fetch those defined in a particular
evolution.
Along with checking an evolution's specified dependencies,
get_evolution_dependencies()
will also check if any mutations have
dependencies to inject. This is a new feature of mutations.
Currently only MoveToDjangoMigrations
implements mutation-defined
dependencies, and ensures that the evolution will apply after the
migrations it applies to. This ensures that for a new database (or new
app), the migrations will always apply first (since the intent is to
ultimately have the app use them instead of evolutions). For an existing
app, the evolver will already make sure those migrations are marked as
applied by scanning ahead for this mutation, and it's important that the
evolution doesn't try to apply before this step happens.
Upcoming changes will factor the dependencies in when determining the
order in which migrations and evolutions will apply.
Unit tests pass.
Made use of this with upcoming changes to implement full dependency
support.
Summary | ID |
---|---|
deb683e014dad3af505f66af8692ea603f522e3f |
Change Summary:
Folded changes for mutation-defined dependencies into this change.
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Commits: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diff: |
Revision 2 (+740) |
Checks run (2 succeeded)
Change Summary:
- Migration dependencies can no longer just specify an app label. They must be a tuple.
- Added "real" migrations to
migrations_app
, to ease testing. - Added new
evolutions_app2
andmigrations_app2
modules to work as anchor points for deps in tests. - Updated the deps in
app_deps_app
andevolution_deps_app
to point to real modules instead of fake ones.
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Commits: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diff: |
Revision 3 (+914 -4) |
Checks run (2 succeeded)
Change Summary:
- Added models to the migration test apps and actual migrations.
- Fixed up dependencies in
evolutions_app2
to be real and not fake. - Updated a unit test suite to use
MigrationsTestsMixin
, and expanded that mixin to clear migrations frommigrations_app
andmigrations_app2
.
Commits: |
|
|||||||
---|---|---|---|---|---|---|---|---|
Diff: |
Revision 4 (+1032 -16) |