Пример #1
0
 /**
  * An application should only have one leaf node more than that means there is an issue somewhere.
  *
  * @return array
  *
  * @since 1.1.0
  *
  * @author Eddilbert Macharia (http://eddmash.com) <edd.cowan@gmail.com>
  */
 public function detectConflicts()
 {
     $latest = $this->graph->getLeafNodes();
     if (count($latest) > 1) {
         return $latest;
     }
     return [];
 }
Пример #2
0
 /**
  * @param array  $changes
  * @param Graph  $graph
  * @param string $migrationName
  *
  * @return mixed
  *
  * @since 1.1.0
  *
  * @author Eddilbert Macharia (http://eddmash.com) <edd.cowan@gmail.com>
  */
 private function _arrangeForGraph($changes, $graph, $migrationName = null)
 {
     $leaves = $graph->getLeafNodes();
     $leaf = empty($leaves) ? '' : $leaves[0];
     if (empty($leaf)) {
         $migrationNo = 1;
     } else {
         $migrationNo = $this->getMigrationNumber(Migration::createShortName($leaf)) + 1;
     }
     /** @var $migration Migration */
     foreach ($changes as $index => &$migration) {
         // set name for migration
         if (empty($leaf)) {
             // this mean we don't have previous migrations
             $migrationName = $this->suggestName();
         } else {
             // first set previous as dependency of this
             // $migration->requires = [$leaf];
             $migration->setDependency($leaf);
             $migrationNo = str_pad($migrationNo, 4, '0', STR_PAD_LEFT);
             $migrationName = $this->suggestName($migration->getOperations(), $migrationNo);
         }
         $migration->setName($migrationName);
     }
     return $changes;
 }