Ticket #26180: ticket26180-temp-fix.diff
File ticket26180-temp-fix.diff, 2.2 KB (added by , 8 years ago) |
---|
-
django/db/migrations/autodetector.py
diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py index ae88a90..d102c19 100644
a b class MigrationAutodetector(object): 351 351 # Optimize migrations 352 352 for app_label, migrations in self.migrations.items(): 353 353 for migration in migrations: 354 migration.operations = MigrationOptimizer().optimize(migration.operations, app_label=app_label) 354 opt_operations = MigrationOptimizer().optimize(migration.operations, app_label=app_label) 355 # Preserve the order if no optmization took place 356 if len(opt_operations) < len(migration.operations): 357 migration.operations = opt_operations 355 358 356 359 def check_dependency(self, operation, dependency): 357 360 """ -
tests/migrations/test_autodetector.py
diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py index 68c4e85..0370f52 100644
a b class AutodetectorTests(TestCase): 1233 1233 ) 1234 1234 # Right number/type of migrations? 1235 1235 self.assertNumberMigrations(changes, "otherapp", 1) 1236 self.assertOperationTypes(changes, "otherapp", 0, [" RemoveField", "AlterUniqueTogether", "AlterIndexTogether"])1237 self.assertOperationAttributes(changes, "otherapp", 0, 0, model_name="book", name="newfield")1238 self.assertOperationAttributes(changes, "otherapp", 0, 1, name="book", unique_together={("author", "title")})1239 self.assertOperationAttributes(changes, "otherapp", 0, 2, name="book", index_together={("author", "title")})1236 self.assertOperationTypes(changes, "otherapp", 0, ["AlterUniqueTogether", "AlterIndexTogether", "RemoveField"]) 1237 self.assertOperationAttributes(changes, "otherapp", 0, 0, name="book", unique_together={("author", "title")}) 1238 self.assertOperationAttributes(changes, "otherapp", 0, 1, name="book", index_together={("author", "title")}) 1239 self.assertOperationAttributes(changes, "otherapp", 0, 2, model_name="book", name="newfield") 1240 1240 1241 1241 def test_rename_field_and_foo_together(self): 1242 1242 """