public function buildGraph() { if (!empty($this->connection)) { $recoder = new Recorder($this->connection); $this->appliedMigrations = $recoder->getApplied(); } $migrations = $this->getMigrations(); $this->graph = new Graph(); // first add all the migrations into the graph foreach ($migrations as $name => $migration) { $this->graph->addNode($name, $migration); } // the for each migration set its dependencies /** @var $migration Migration */ foreach ($migrations as $name => $migration) { foreach ($migration->getDependency() as $parent) { $this->graph->addDependency($name, $parent, $migration); } } }