mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[1.8.x] Fixed #24628 -- Fixed applied status for squashed migrations.
Backport of 492537ac18 from master.
			
			
This commit is contained in:
		| @@ -110,6 +110,7 @@ class MigrationExecutor(object): | ||||
|                 self.apply_migration(states[migration], migration, fake=fake, fake_initial=fake_initial) | ||||
|             else: | ||||
|                 self.unapply_migration(states[migration], migration, fake=fake) | ||||
|         self.check_replacements() | ||||
|  | ||||
|     def collect_sql(self, plan): | ||||
|         """ | ||||
| @@ -176,6 +177,16 @@ class MigrationExecutor(object): | ||||
|             self.progress_callback("unapply_success", migration, fake) | ||||
|         return state | ||||
|  | ||||
|     def check_replacements(self): | ||||
|         """ | ||||
|         Mark replacement migrations applied if their replaced set all are. | ||||
|         """ | ||||
|         applied = self.recorder.applied_migrations() | ||||
|         for key, migration in self.loader.replacements.items(): | ||||
|             all_applied = all(m in applied for m in migration.replaces) | ||||
|             if all_applied and key not in applied: | ||||
|                 self.recorder.record_applied(*key) | ||||
|  | ||||
|     def detect_soft_applied(self, project_state, migration): | ||||
|         """ | ||||
|         Tests whether a migration has been implicitly applied - that the | ||||
|   | ||||
| @@ -249,6 +249,8 @@ class MigrationLoader(object): | ||||
|             # Mark the replacement as applied if all its replaced ones are | ||||
|             if all(applied_statuses): | ||||
|                 self.applied_migrations.add(key) | ||||
|         # Store the replacement migrations for later checks | ||||
|         self.replacements = replacing | ||||
|         # Finally, make a graph and load everything into it | ||||
|         self.graph = MigrationGraph() | ||||
|         for key, migration in normal.items(): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user