コード例 #1
0
 public function test_migrate()
 {
     $this->migration->shouldReceive('getMigration')->andReturn($this->dbalMig);
     $this->migration->shouldReceive('getConfiguration')->andReturn($this->configuration);
     $this->configuration->shouldReceive('getVersion')->andReturn(m::mock(Version::class));
     $this->migration->shouldReceive('getVersion')->andReturn('version1');
     $this->dbalMig->shouldReceive('migrate')->with('version1', false, false)->andReturn(['version1' => 'SQL']);
     $migrator = new Migrator();
     $migrator->migrate($this->migration);
     $this->assertContains('<info>Migrated:</info> version1', $migrator->getNotes());
 }
コード例 #2
0
 /**
  * Execute the console command.
  *
  * @param ConfigurationProvider $provider
  * @param Migrator              $migrator
  */
 public function fire(ConfigurationProvider $provider, Migrator $migrator)
 {
     if (!$this->confirmToProceed()) {
         return;
     }
     $configuration = $provider->getForConnection($this->option('connection'));
     $version = $this->argument('version');
     $direction = $this->option('down') ? 'down' : 'up';
     $version = $configuration->getVersion($version);
     if ($path = $this->option('write-sql')) {
         $migrator->executeToFile($version, $direction, $path);
     } else {
         $migrator->execute($version, $direction, $this->option('dry-run'), $this->option('query-time'));
     }
     foreach ($migrator->getNotes() as $note) {
         $this->line($note);
     }
 }
コード例 #3
0
 /**
  * Execute the console command.
  *
  * @param ConfigurationProvider $provider
  * @param Migrator              $migrator
  *
  * @throws \Doctrine\DBAL\Migrations\MigrationException
  * @return int
  */
 public function fire(ConfigurationProvider $provider, Migrator $migrator)
 {
     if (!$this->confirmToProceed()) {
         return;
     }
     $configuration = $provider->getForConnection($this->option('connection') ?: null);
     try {
         $migration = new Migration($configuration, $this->argument('version'));
     } catch (ExecutedUnavailableMigrationsException $e) {
         $this->handleExecutedUnavailableMigrationsException($e, $configuration);
     } catch (MigrationVersionException $e) {
         $this->error($e->getMessage());
     }
     if ($path = $this->option('write-sql')) {
         $migrator->migrateToFile($migration, $path);
     } else {
         $migrator->migrate($migration, $this->option('dry-run') ? true : false, $this->option('query-time') ? true : false);
     }
     foreach ($migrator->getNotes() as $note) {
         $this->line($note);
     }
 }