Factored out per-model index generation code.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3890 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
67eabb9299
commit
d886e71f2b
|
@ -398,10 +398,19 @@ get_sql_sequence_reset.args = APP_ARGS
|
|||
|
||||
def get_sql_indexes(app):
|
||||
"Returns a list of the CREATE INDEX SQL statements for the given app."
|
||||
from django.db import backend, models
|
||||
from django.db import models
|
||||
output = []
|
||||
for model in models.get_models(app):
|
||||
output.extend(_get_sql_index(model))
|
||||
return output
|
||||
get_sql_indexes.help_doc = "Prints the CREATE INDEX SQL statements for the given model module name(s)."
|
||||
get_sql_indexes.args = APP_ARGS
|
||||
|
||||
def _get_sql_index(model):
|
||||
"Returns the CREATE INDEX SQL statements for a specific model"
|
||||
from django.db import backend
|
||||
output = []
|
||||
|
||||
for model in models.get_models(app):
|
||||
for f in model._meta.fields:
|
||||
if f.db_index:
|
||||
unique = f.unique and 'UNIQUE ' or ''
|
||||
|
@ -413,8 +422,6 @@ def get_sql_indexes(app):
|
|||
"(%s);" % style.SQL_FIELD(backend.quote_name(f.column))
|
||||
)
|
||||
return output
|
||||
get_sql_indexes.help_doc = "Prints the CREATE INDEX SQL statements for the given model module name(s)."
|
||||
get_sql_indexes.args = APP_ARGS
|
||||
|
||||
def get_sql_all(app):
|
||||
"Returns a list of CREATE TABLE SQL, initial-data inserts, and CREATE INDEX SQL for the given module."
|
||||
|
|
Loading…
Reference in New Issue