예제 #1
0
 public function execute($args)
 {
     array_shift($args);
     // Remove the phinx command
     $a = new PhinxApplication();
     $a->run(new ArgvInput($args));
 }
예제 #2
0
 public function __call($name, $arguments)
 {
     $config_path = Registry::get('config.dir.root') . '/app/Tygh/UpgradeCenter/Migrations/config.migrations.php';
     switch ($name) {
         case 'migrate':
             $_SERVER['argv'] = array('phinx', 'migrate', '-c' . $config_path, '-edevelopment');
             break;
         case 'rollback':
             $_SERVER['argv'] = array('phinx', 'rollback', '-c' . $config_path, '-edevelopment');
             break;
         default:
             return false;
     }
     $output = new Output();
     $output->setConfig($this->config);
     $output->setVerbosity(Output::VERBOSITY_VERBOSE);
     $app = new PhinxApplication('0.4.3');
     AdapterFactory::instance()->registerAdapter('mysqli', '\\Tygh\\UpgradeCenter\\Phinx\\MysqliAdapter');
     $app->setAutoExit(false);
     $app->setCatchExceptions(false);
     try {
         $exit_code = $app->run(null, $output);
     } catch (\Exception $e) {
         // Convert PDOException to DatabaseException
         if (class_exists('\\PDOException') && $e instanceof \PDOException) {
             throw new DatabaseException($e->getMessage(), $e->getCode(), $e);
         } else {
             throw $e;
         }
     }
     return $exit_code === 0;
 }
예제 #3
0
 protected function migrate()
 {
     $input = new ArgvInput(['phinx', 'migrate', '--environment=memory']);
     $output = new NullOutput();
     $phinx = new PhinxApplication();
     $phinx->setAutoExit(false);
     $phinx->run($input, $output);
     /** @var Migrate $migrateCommand */
     $migrateCommand = $phinx->get('migrate');
     $adapter = $migrateCommand->getManager()->getEnvironment('memory')->getAdapter();
     /** @var PDO $pdo */
     $this->phinxPdo = $adapter->getConnection();
 }
예제 #4
0
 public function __call($name, $arguments)
 {
     $config_path = Registry::get('config.dir.root') . '/app/Tygh/UpgradeCenter/Migrations/config.migrations.php';
     switch ($name) {
         case 'migrate':
             $_SERVER['argv'] = array('phinx', 'migrate', '-c' . $config_path, '-edevelopment');
             break;
         case 'rollback':
             $_SERVER['argv'] = array('phinx', 'rollback', '-c' . $config_path, '-edevelopment');
             break;
         default:
             return false;
     }
     $output = new Output();
     $output->setConfig($this->config);
     $app = new PhinxApplication('0.4.3');
     AdapterFactory::instance()->registerAdapter('mysqli', '\\Tygh\\UpgradeCenter\\Phinx\\MysqliAdapter');
     $app->setAutoExit(false);
     $app->run(null, $output);
 }