Add new utilities for working with databases and models.
Review Request #10562 — Created May 22, 2019 and submitted — Latest diff uploaded
sql_create()
, a utility function for generating the SQL for creating
an app's models, has been renamed tosql_create_app()
, and its
model-creating functionality split out intosql_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()
anddb_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 (usingsql_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 newdb_router_allows_schema_upgrade()
.
Unit tests pass on Django 1.6 and 1.11.