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); } } }
/** * Applies the migration to the database. * * @param ProjectState $state this is the state before the migration is applied * @param Migration $migration the migration to apply * @param bool $fake * * @return mixed * * @since 1.1.0 * * @author Eddilbert Macharia (http://eddmash.com) <*****@*****.**> */ public function applyMigration($state, $migration, $fake = false) { Console::stdout(sprintf(' Applying %s...', $migration->getName())); if (!$fake) { $state = $migration->apply($state, $this->schemaEditor); } $this->recorder->recordApplied(['name' => $migration->getName()]); if ($fake) { $end = Console::ansiFormat('FAKED', [Console::FG_GREEN]); } else { $end = Console::ansiFormat('OK', [Console::FG_GREEN]); } Console::stdout($end . PHP_EOL); return $state; }