| 103 | # Install SQL indicies for all newly created models |
| 104 | for app in models.get_apps(): |
| 105 | app_name = app.__name__.split('.')[-2] |
| 106 | for model in models.get_models(app): |
| 107 | if model in created_models: |
| 108 | index_sql = connection.creation.sql_indexes_for_model(model, self.style) |
| 109 | if index_sql: |
| 110 | if verbosity >= 1: |
| 111 | print "Installing index for %s.%s model" % (app_name, model._meta.object_name) |
| 112 | try: |
| 113 | for sql in index_sql: |
| 114 | cursor.execute(sql) |
| 115 | except Exception, e: |
| 116 | sys.stderr.write("Failed to install index for %s.%s model: %s\n" % \ |
| 117 | (app_name, model._meta.object_name, e)) |
| 118 | transaction.rollback_unless_managed() |
| 119 | else: |
| 120 | transaction.commit_unless_managed() |
| 121 | |
128 | | # Install SQL indicies for all newly created models |
129 | | for app in models.get_apps(): |
130 | | app_name = app.__name__.split('.')[-2] |
131 | | for model in models.get_models(app): |
132 | | if model in created_models: |
133 | | index_sql = connection.creation.sql_indexes_for_model(model, self.style) |
134 | | if index_sql: |
135 | | if verbosity >= 1: |
136 | | print "Installing index for %s.%s model" % (app_name, model._meta.object_name) |
137 | | try: |
138 | | for sql in index_sql: |
139 | | cursor.execute(sql) |
140 | | except Exception, e: |
141 | | sys.stderr.write("Failed to install index for %s.%s model: %s\n" % \ |
142 | | (app_name, model._meta.object_name, e)) |
143 | | transaction.rollback_unless_managed() |
144 | | else: |
145 | | transaction.commit_unless_managed() |