MCPcopy
hub / github.com/django/django / check_key

Method check_key

django/db/migrations/loader.py:171–199  ·  view source on GitHub ↗
(self, key, current_app)

Source from the content-addressed store, hash-verified

169 return self.disk_migrations[results[0]]
170
171 def check_key(self, key, current_app):
172 if (key[1] != "__first__" and key[1] != "__latest__") or key in self.graph:
173 return key
174 # Special-case __first__, which means "the first migration" for
175 # migrated apps, and is ignored for unmigrated apps. It allows
176 # makemigrations to declare dependencies on apps before they even have
177 # migrations.
178 if key[0] == current_app:
179 # Ignore __first__ references to the same app (#22325)
180 return
181 if key[0] in self.unmigrated_apps:
182 # This app isn't migrated, but something depends on it.
183 # The models will get auto-added into the state, though
184 # so we're fine.
185 return
186 if key[0] in self.migrated_apps:
187 try:
188 if key[1] == "__first__":
189 return self.graph.root_nodes(key[0])[0]
190 else: # "__latest__"
191 return self.graph.leaf_nodes(key[0])[0]
192 except IndexError:
193 if self.ignore_no_migrations:
194 return None
195 else:
196 raise ValueError(
197 "Dependency on app with no migrations: %s" % key[0]
198 )
199 raise ValueError("Dependency on unknown app: %s" % key[0])
200
201 def add_internal_dependencies(self, key, migration):
202 """

Callers 1

Calls 2

root_nodesMethod · 0.80
leaf_nodesMethod · 0.80

Tested by

no test coverage detected