Add new utilities for working with databases and models.

Review Request #10562 — Created May 22, 2019 and submitted — Latest diff uploaded

Information

Django Evolution
master

Reviewers

sql_create(), a utility function for generating the SQL for creating
an app's models, has been renamed to sql_create_app(), and its
model-creating functionality split out into sql_create_models(). This
allows callers to generate suitable SQL for creating only a subset of
models for an app, or several models for several apps.

db_router_allows_schema_upgrade() is a new wrapper around
db_router_allows_migrate() and db_router_allows_syncdb(),
simplifying the work required by a caller.

db_get_installable_models_for_app() returns all models that can be
installed in the database (using sql_create_models() or another
operation). It takes care of returning models suitable for the preferred
creation mechanism used on the running version of Django, and handles
checking the router using the new db_router_allows_schema_upgrade().

Unit tests pass on Django 1.6 and 1.11.

Commits

Files