/** * setup method * * @return void */ public function setUp() { parent::setUp(); $this->Connection = ConnectionManager::get('test'); $connectionConfig = $this->Connection->config(); $this->Connection->execute('DROP TABLE IF EXISTS phinxlog'); $this->config = new Config(['paths' => ['migrations' => __FILE__], 'environments' => ['default_migration_table' => 'phinxlog', 'default_database' => 'cakephp_test', 'default' => ['adapter' => getenv('DB'), 'host' => '127.0.0.1', 'name' => !empty($connectionConfig['database']) ? $connectionConfig['database'] : '', 'user' => !empty($connectionConfig['username']) ? $connectionConfig['username'] : '', 'pass' => !empty($connectionConfig['password']) ? $connectionConfig['password'] : '']]]); $application = new MigrationsDispatcher('testing'); $output = new StreamOutput(fopen('php://memory', 'a', false)); $this->command = $application->find('mark_migrated'); $Environment = new Environment('default', $this->config['environments']['default']); $Manager = $this->getMock('\\Phinx\\Migration\\Manager', [], [$this->config, $output]); $Manager->expects($this->any())->method('getEnvironment')->will($this->returnValue($Environment)); $this->command->setManager($Manager); }
/** * This acts as a front-controller for phinx. It just instantiates the classes * responsible for parsing the command line from phinx and gives full control of * the rest of the flow to it. * * The input parameter of the ``MigrationDispatcher::run()`` method is manually built * in case a MigrationsShell is dispatched using ``Shell::dispatch()``. * * @return void */ public function main() { $app = new MigrationsDispatcher(PHINX_VERSION); $input = new ArgvInput($this->argv); $app->setAutoExit(false); $app->run($input); }
/** * This acts as a front-controller for phinx. It just instantiates the classes * responsible for parsing the command line from phinx and gives full control of * the rest of the flow to it. * * @return void */ public function main() { array_shift($_SERVER['argv']); $_SERVER['argv']--; $app = new MigrationsDispatcher(PHINX_VERSION); $app->run(); }
/** * This acts as a front-controller for phinx. It just instantiates the classes * responsible for parsing the command line from phinx and gives full control of * the rest of the flow to it. * * The input parameter of the ``MigrationDispatcher::run()`` method is manually built * in case a MigrationsShell is dispatched using ``Shell::dispatch()``. * * @return void */ public function main() { $app = new MigrationsDispatcher(PHINX_VERSION); $input = new ArgvInput($this->argv); $app->setAutoExit(false); $exitCode = $app->run($input); if (isset($this->argv[1]) && in_array($this->argv[1], ['migrate', 'rollback']) && $exitCode === 0) { $dispatchCommand = 'migrations dump'; if (!empty($this->params['connection'])) { $dispatchCommand .= ' -c ' . $this->params['connection']; } if (!empty($this->params['plugin'])) { $dispatchCommand .= ' -p ' . $this->params['plugin']; } $this->dispatchShell($dispatchCommand); } }
protected function runMigrations($action = 'migrate', $plugin = null) { $args = ['migrations', $action, '-q']; if ($action == 'rollback') { $args = array_merge($args, ['-t', 0]); } if ($plugin) { $args = array_merge($args, ['--plugin', $plugin]); } //debug($args); $app = new MigrationsDispatcher(PHINX_VERSION); $app->setAutoExit(false); // -q disable verbosing $input = new ArgvInput($args); $app->run($input); }