/var/www/vhosts/ihelp.ro/_OLD/vendor/robmorgan/phinx/src/Phinx/Console/Command
Edit: /var/www/vhosts/ihelp.ro/_OLD/vendor/robmorgan/phinx/src/Phinx/Console/Command/Migrate.php (4979B)
addOption('--environment', '-e', InputOption::VALUE_REQUIRED, 'The target environment');
$this->setDescription('Migrate the database')
->addOption('--target', '-t', InputOption::VALUE_REQUIRED, 'The version number to migrate to')
->addOption('--date', '-d', InputOption::VALUE_REQUIRED, 'The date to migrate to')
->addOption('--dry-run', '-x', InputOption::VALUE_NONE, 'Dump query to standard output instead of executing it')
->addOption('--fake', null, InputOption::VALUE_NONE, "Mark any migrations selected as run, but don't actually execute them")
->setHelp(
<<
migrate command runs all available migrations, optionally up to a specific version
phinx migrate -e development
phinx migrate -e development -t 20110103081132
phinx migrate -e development -d 20110103
phinx migrate -e development -v
EOT
);
}
/**
* Migrate the database.
*
* @param \Symfony\Component\Console\Input\InputInterface $input Input
* @param \Symfony\Component\Console\Output\OutputInterface $output Output
*
* @return int integer 0 on success, or an error code.
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->bootstrap($input, $output);
$version = $input->getOption('target');
$environment = $input->getOption('environment');
$date = $input->getOption('date');
$fake = (bool)$input->getOption('fake');
if ($environment === null) {
$environment = $this->getConfig()->getDefaultEnvironment();
$output->writeln('warning no environment specified, defaulting to: ' . $environment);
} else {
$output->writeln('using environment ' . $environment);
}
if (!$this->getConfig()->hasEnvironment($environment)) {
$output->writeln(sprintf('The environment "%s" does not exist', $environment));
return self::CODE_ERROR;
}
$envOptions = $this->getConfig()->getEnvironment($environment);
if (isset($envOptions['adapter'])) {
$output->writeln('using adapter ' . $envOptions['adapter']);
}
if (isset($envOptions['wrapper'])) {
$output->writeln('using wrapper ' . $envOptions['wrapper']);
}
if (isset($envOptions['name'])) {
$output->writeln('using database ' . $envOptions['name']);
} else {
$output->writeln('Could not determine database name! Please specify a database name in your config file.');
return self::CODE_ERROR;
}
if (isset($envOptions['table_prefix'])) {
$output->writeln('using table prefix ' . $envOptions['table_prefix']);
}
if (isset($envOptions['table_suffix'])) {
$output->writeln('using table suffix ' . $envOptions['table_suffix']);
}
$versionOrder = $this->getConfig()->getVersionOrder();
$output->writeln('ordering by ' . $versionOrder . ' time');
if ($fake) {
$output->writeln('warning performing fake migrations');
}
try {
// run the migrations
$start = microtime(true);
if ($date !== null) {
$this->getManager()->migrateToDateTime($environment, new DateTime($date), $fake);
} else {
if ($version) {
$version = (int)$version;
}
$this->getManager()->migrate($environment, $version, $fake);
}
$end = microtime(true);
} catch (Exception $e) {
$output->writeln('' . $e->__toString() . '');
return self::CODE_ERROR;
} catch (Throwable $e) {
$output->writeln('' . $e->__toString() . '');
return self::CODE_ERROR;
}
$output->writeln('');
$output->writeln('All Done. Took ' . sprintf('%.4fs', $end - $start) . '');
return self::CODE_SUCCESS;
}
}