execute() public method

We are only allowing the addSql call and the schema modification to take effect in the up and down call. This is necessary to ensure that the migration is revertable. The schema is passed to the pre and post method only to be able to test the presence of some table, And the connection that can get used trough it allow for the test of the presence of records.
public execute ( string $direction, boolean $dryRun = false, boolean $timeAllQueries = false ) : array
$direction string The direction to execute the migration.
$dryRun boolean Whether to not actually execute the migration SQL and just do a dry run.
$timeAllQueries boolean Measuring or not the execution time of each SQL query.
return array $sql
Exemplo n.º 1
0
 /**
  * @param Version    $version
  * @param            $direction
  * @param bool|false $dryRun
  * @param bool|false $timeQueries
  */
 public function execute(Version $version, $direction, $dryRun = false, $timeQueries = false)
 {
     $version->execute($direction, $dryRun, $timeQueries);
     $verb = $direction === 'down' ? 'Rolled back' : 'Migrated';
     $this->note($version->getVersion(), $version, $timeQueries, $verb);
 }
Exemplo n.º 2
0
 public function testCatchExceptionDuringMigration()
 {
     $this->outputWriter = $this->getOutputWriter();
     $this->config = new Configuration($this->getSqliteConnection(), $this->outputWriter);
     $this->config->setMigrationsDirectory(\sys_get_temp_dir());
     $this->config->setMigrationsNamespace('DoctrineMigrations\\');
     $version = new Version($this->config, $versionName = '004', 'Doctrine\\DBAL\\Migrations\\Tests\\Stub\\VersionDummyException');
     try {
         $version->execute('up');
     } catch (\Exception $e) {
         $this->assertContains('Migration 004 failed during Execution. Error Super Exception', $this->getOutputStreamContent($this->output));
     }
 }