Refs #1828 -- Added creation of indexes as a step in syncdb. This is an interim solution; the long term solution requires a non-trivial refactoring of syncdb, install and the get_* calls in management.py. Thanks to mdt@emdete.de for the original report, and to Simon Greenhill for prodding me to an interim fix.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3893 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
b08a8dbb65
commit
f5087775b3
|
@ -522,6 +522,25 @@ def syncdb(verbosity=1, interactive=True):
|
|||
else:
|
||||
transaction.commit_unless_managed()
|
||||
|
||||
# Install SQL indicies for all newly created models
|
||||
for app in models.get_apps():
|
||||
app_name = app.__name__.split('.')[-2]
|
||||
for model in models.get_models(app):
|
||||
if model in created_models:
|
||||
index_sql = _get_sql_index(model)
|
||||
if index_sql:
|
||||
if verbosity >= 1:
|
||||
print "Installing index for %s.%s model" % (app_name, model._meta.object_name)
|
||||
try:
|
||||
for sql in index_sql:
|
||||
cursor.execute(sql)
|
||||
except Exception, e:
|
||||
sys.stderr.write("Failed to install index for %s.%s model: %s" % \
|
||||
(app_name, model._meta.object_name, e))
|
||||
transaction.rollback_unless_managed()
|
||||
else:
|
||||
transaction.commit_unless_managed()
|
||||
|
||||
syncdb.args = ''
|
||||
|
||||
def get_admin_index(app):
|
||||
|
|
Loading…
Reference in New Issue