mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[1.7.x] Fixed #22848: Ignore no-migrations errors during makemigrations only
This commit is contained in:
		| @@ -51,7 +51,7 @@ class Command(BaseCommand): | |||||||
|  |  | ||||||
|         # Load the current graph state. Pass in None for the connection so |         # Load the current graph state. Pass in None for the connection so | ||||||
|         # the loader doesn't try to resolve replaced migrations from DB. |         # the loader doesn't try to resolve replaced migrations from DB. | ||||||
|         loader = MigrationLoader(None) |         loader = MigrationLoader(None, ignore_no_migrations=True) | ||||||
|  |  | ||||||
|         # Before anything else, see if there's conflicting apps and drop out |         # Before anything else, see if there's conflicting apps and drop out | ||||||
|         # hard if there are any and they don't want to merge |         # hard if there are any and they don't want to merge | ||||||
|   | |||||||
| @@ -39,10 +39,11 @@ class MigrationLoader(object): | |||||||
|     in memory. |     in memory. | ||||||
|     """ |     """ | ||||||
|  |  | ||||||
|     def __init__(self, connection, load=True): |     def __init__(self, connection, load=True, ignore_no_migrations=False): | ||||||
|         self.connection = connection |         self.connection = connection | ||||||
|         self.disk_migrations = None |         self.disk_migrations = None | ||||||
|         self.applied_migrations = None |         self.applied_migrations = None | ||||||
|  |         self.ignore_no_migrations = ignore_no_migrations | ||||||
|         if load: |         if load: | ||||||
|             self.build_graph() |             self.build_graph() | ||||||
|  |  | ||||||
| @@ -156,7 +157,10 @@ class MigrationLoader(object): | |||||||
|                 else: |                 else: | ||||||
|                     return list(self.graph.root_nodes(key[0]))[-1] |                     return list(self.graph.root_nodes(key[0]))[-1] | ||||||
|             except IndexError: |             except IndexError: | ||||||
|                 raise ValueError("Dependency on app with no migrations: %s" % key[0]) |                 if self.ignore_no_migrations: | ||||||
|  |                     return None | ||||||
|  |                 else: | ||||||
|  |                     raise ValueError("Dependency on app with no migrations: %s" % key[0]) | ||||||
|         raise ValueError("Dependency on unknown app: %s" % key[0]) |         raise ValueError("Dependency on unknown app: %s" % key[0]) | ||||||
|  |  | ||||||
|     def build_graph(self): |     def build_graph(self): | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user