public function __construct(Version $version)
 {
     $this->configuration = $version->getConfiguration();
     $this->outputWriter = $this->configuration->getOutputWriter();
     $this->connection = $this->configuration->getConnection();
     $this->connection = $this->connection->selectDatabase($this->configuration->getMigrationsDatabaseName());
     $this->version = $version;
 }
Ejemplo n.º 2
0
 /**
  * Check if we should execute a migration for a given direction and target
  * migration version.
  *
  * @param string  $direction The direction we are migrating.
  * @param Version $version   The Version instance to check.
  * @param string  $to        The version we are migrating to.
  * @param array   $migrated  Migrated versions array.
  *
  * @return boolean
  */
 private function shouldExecuteMigration($direction, Version $version, $to, $migrated)
 {
     if ($direction === 'down') {
         if (!in_array($version->getVersion(), $migrated)) {
             return false;
         }
         return $version->getVersion() > $to;
     }
     if ($direction === 'up') {
         if (in_array($version->getVersion(), $migrated)) {
             return false;
         }
         return $version->getVersion() <= $to;
     }
 }