/**
  * @param InputInterface $input
  * @return bool
  */
 protected function execute(InputInterface $input)
 {
     $this->inputInterface = $input;
     $fromArg = $input->getArgument('from');
     $sourceEnvironment = Environment::get($fromArg);
     $toArg = $this->getDestinationEnvironment();
     $destEnvironment = Environment::get($toArg);
     $sourceDatabase = new Database($sourceEnvironment);
     $destinationDatabase = new Database($destEnvironment);
     $this->consoleOutput->output('Starting pulling <fg=magenta>' . $input->getArgument('from') . '</> database...');
     $sourceResult = $sourceDatabase->exportSql();
     if ($sourceResult->isFailed()) {
         $this->consoleOutput->output('<fg=red>Error!!</> Pulling <fg=magenta>' . $input->getArgument('from') . '</> wasn\'t successfull.');
         $this->consoleOutput->output('<fg=default>Please</> check your Logs for more Information.');
         return -1;
     } else {
         $this->consoleOutput->output('<fg=green>Success!!</> Pulling <fg=magenta>' . $input->getArgument('from') . '</> was successfull.');
     }
     $this->consoleOutput->output('Starting importing <fg=magenta>' . $this->getDestinationEnvironment() . '</> database...');
     $destinationResult = $destinationDatabase->importSql($sourceResult->getPath());
     if ($destinationResult->isFailed()) {
         $this->consoleOutput->output('<fg=red>Error!!</> Importing <fg=magenta>' . $this->getDestinationEnvironment() . '</> wasn\'t successfull.');
         $this->consoleOutput->output('<fg=default>Please</> check your Logs for more Information.');
         return -1;
     } else {
         $this->consoleOutput->output('<fg=green>Success!!</> Importing <fg=magenta>' . $this->getDestinationEnvironment() . '</> was successfull.');
     }
     return 0;
 }
Example #2
0
 /**
  * @return array
  * @throws \Exception
  */
 protected function createEnvironments()
 {
     $result = [];
     $result[] = Environment::create('live');
     $result[] = Environment::create('local');
     $result[] = Environment::create('development');
     $result[] = Environment::create('staging');
     return $result;
 }
Example #3
0
 /**
  * @test
  * @return void
  */
 public function testEnvironmentWillAssignVars()
 {
     $config = array('database' => array('username' => 'username', 'password' => 'password', 'host' => 'host', 'database' => 'database'), 'ssh_tunnel' => array('enabled' => true, 'host' => 'host', 'username' => 'username'));
     $env = new Environment($config);
     $this->assertSame('username', $env->getUsername());
     $this->assertSame('password', $env->getPassword());
     $this->assertSame('host', $env->getHost());
     $this->assertSame('database', $env->getDatabase());
     $this->assertSame('username', $env->getSshUsername());
     $this->assertSame('host', $env->getSshHost());
     $this->assertTrue($env->isSshTunnel());
 }
Example #4
0
 /**
  * @param $pathFile
  * @return DatabaseResult
  * @throws \Exception
  */
 public function importSql($pathFile)
 {
     if (!file_exists($pathFile)) {
         throw new \Exception('File not exists.', 1456234084);
     }
     if ($this->environment->isSshTunnel()) {
         $shellResults = $this->tunneledDatabaseImport($pathFile);
     } else {
         $shellResults = $this->databaseImport($pathFile);
     }
     $databaseResult = new DatabaseResult();
     $databaseResult->setShellResults($shellResults);
     $databaseResult->setFailed($this->checkResultsAreFailed($shellResults));
     return $databaseResult;
 }