code: def get_migrations_dir(graph):
      
      try:
          migrations_dir = graph.migrations_dir
      except (LockedGraphError, NotBoundError):
          migrations_dir = graph.metadata.get_path("migrations")
  
      if not isdir(migrations_dir):
          raise Exception("Migrations dir must exist: {}".format(migrations_dir))
      return migrations_dir
docs: Resolve the migrations directory path.
  
      Either take the directory from a component of the object graph or by
      using the metaata's path resolution facilities.