Ticket #1828: 1828.diff

File 1828.diff, 1.4 KB (added by dev@…, 18 years ago)
  • management.py

     
    454454    # Get a list of already installed *models* so that references work right.
    455455    seen_models = _get_installed_models(table_list)
    456456    created_models = set()
     457    created_apps = set()
    457458    pending_references = {}
    458459
    459460    for app in models.get_apps():
     
    465466            sql, references = _get_sql_model_create(model, seen_models)
    466467            seen_models.add(model)
    467468            created_models.add(model)
     469            created_apps.add(app)
    468470            for refto, refs in references.items():
    469471                try:
    470472                    pending_references[refto].extend(refs)
     
    512514                        transaction.rollback_unless_managed()
    513515                    else:
    514516                        transaction.commit_unless_managed()
     517       
     518    # do indexes - doing it after initial sql, it should speed up the inserts on at least MySQL
     519    # (i.e. one re-index rather than n re-indexes)
     520    for app in created_apps:
     521        print "Creating indexes for %s" % app.__name__
     522        for sql in get_sql_indexes(app):
     523            try:
     524                cursor.execute(sql)
     525            except Exception, e:
     526                sys.stderr.write("Failed to create index for %s app: %s" % app.__name__, e)
    515527
    516528syncdb.args = ''
Back to Top