              for parent in migration.dependencies:
                  if parent[0] != key[0] or parent[1] == '__first__':
                      # Ignore __first__ references to the same app (#22325)
                      continue
                  self.graph.add_dependency(migration, key, parent)
          for key, migration in normal.items():
              for parent in migration.dependencies:
                  if parent[0] == key[0]:
                      # Internal dependencies already added.
                      continue
 
</s> remove                     self.graph.add_dependency(migration, key, parent)
 </s> add                     try:
                        self.graph.add_dependency(migration, key, parent)
                    except NodeNotFoundError as e:
                        # Since we added "key" to the nodes before this implies
                        # "parent" is not in there.
                        _reraise_missing_dependency(migration, parent, e) </s> remove                 else:
 </s> add                 else:  # "__latest__" </s> remove                     self.graph.add_dependency(migration, child, key)
 </s> add                     try:
                        self.graph.add_dependency(migration, child, key)
                    except NodeNotFoundError as e:
                        # Since we added "key" to the nodes before this implies
                        # "child" is not in there.
                        _reraise_missing_dependency(migration, child, e) </s> remove         "Gets the migration exactly named, or raises KeyError"
 </s> add         "Gets the migration exactly named, or raises `graph.NodeNotFoundError`"
                try:
                    self.graph.add_dependency(migration, key, parent)
                except NodeNotFoundError as e:
                    # Since we added "key" to the nodes before this implies
                    # "parent" is not in there. To make the raised exception
                    # more understandable we check if parent could have been
                    # replaced but hasn't (eg partially applied squashed
                    # migration)
                    _reraise_missing_dependency(migration, parent, e)
              for parent in migration.dependencies:
                  if parent[0] != key[0] or parent[1] == '__first__':
                      # Ignore __first__ references to the same app (#22325)
                      continue
                try:
                    self.graph.add_dependency(migration, key, parent)
                except NodeNotFoundError as e:
                    # Since we added "key" to the nodes before this implies
                    # "parent" is not in there. To make the raised exception
                    # more understandable we check if parent could have been
                    # replaced but hasn't (eg partially applied squashed
                    # migration)
                    _reraise_missing_dependency(migration, parent, e)
          for key, migration in normal.items():
              for parent in migration.dependencies:
                  if parent[0] == key[0]:
                      # Internal dependencies already added.
                      continue
keep keep keep keep replace keep keep keep keep keep
 Fixed #23556 -- Raised a more meaningful error message when migrations refer to an unavailable node 
django/db/migrations/loader.py