Neos\Flow\Persistence\Doctrine\Service::executeMigration PHP Метод

executeMigration() публичный Метод

Execute a single migration in up or down direction. If $path is given, the SQL statements will be written to the file in $path instead of executed.
public executeMigration ( string $version, string $direction = 'up', string $outputPathAndFilename = null, boolean $dryRun = false ) : string
$version string The version to migrate to
$direction string
$outputPathAndFilename string A file to write SQL to, instead of executing it
$dryRun boolean Whether to do a dry run or not
Результат string
    public function executeMigration($version, $direction = 'up', $outputPathAndFilename = null, $dryRun = false)
    {
        $version = $this->getMigrationConfiguration()->getVersion($version);
        if ($outputPathAndFilename !== null) {
            $version->writeSqlFile($outputPathAndFilename, $direction);
        } else {
            $version->execute($direction, $dryRun);
        }
        return strip_tags(implode(PHP_EOL, $this->output));
    }

Usage Example

Пример #1
0
 /**
  * Execute a single migration
  *
  * Manually runs a single migration in the given direction.
  *
  * @param string $version The migration to execute
  * @param string $direction Whether to execute the migration up (default) or down
  * @param string $output A file to write SQL to, instead of executing it
  * @param boolean $dryRun Whether to do a dry run or not
  * @return void
  * @see neos.flow:doctrine:migrate
  * @see neos.flow:doctrine:migrationstatus
  * @see neos.flow:doctrine:migrationgenerate
  * @see neos.flow:doctrine:migrationversion
  */
 public function migrationExecuteCommand($version, $direction = 'up', $output = null, $dryRun = false)
 {
     if (!$this->isDatabaseConfigured()) {
         $this->outputLine('Doctrine migration not possible, the driver and host backend options are not set in /Configuration/Settings.yaml.');
         $this->quit(1);
     }
     try {
         $this->outputLine($this->doctrineService->executeMigration($version, $direction, $output, $dryRun));
     } catch (\Exception $exception) {
         $this->handleException($exception);
     }
 }