Only sync/evolve models for enabled extensions when necessary.

Review Request #10249 — Created Oct. 20, 2018 and submitted

Information

Djblets
release-1.0.x
ae22960...

Reviewers

When enabling an extension, we go through a series of steps to ensure
its state is made available both in the database and to the running
application. Part of this involves synchronizing models to the database
and performing evolutions. However, given that this process is a bit
time-consuming and invasive, it's not something we want to run if we
don't have to. Synchronizing and evolving the database isn't a selective
operation -- it applies to all models across all apps -- so we want to
avoid it when possible.

This change makes the process a lot smarter. Now, before attempting to
sync the database, the extension manager will look at the list of apps
provided by the extension and check if any of them provide models. If
so, then the database will be synced. It then looks to see if there are
any unapplied evolutions for the extension before attempting to evolve
the database.

If these operations are not required, they will no longer be performed.

There's still room for future improvement, but they involve much more
careful introspection of the models and the database, and upstream
changes for Django Evolution to allow for selective evolution.

All unit tests pass in Djblets and Review Board.

Ran the rbintegrations test suite against this. It passed, and only
took 12.577s instead of 77.692s (the time required without this
change).

Description From Last Updated

F841 local variable 'extension' is assigned to but never used

reviewbotreviewbot

F401 'django_evolution.models.Version' imported but unused

reviewbotreviewbot

F401 'django_evolution.signature.create_model_sig' imported but unused

reviewbotreviewbot

F841 local variable 'extension' is assigned to but never used

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

flake8

chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-1.0.x (e8d80b9)
Loading...