/var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/migrations/src/Command/Phinx
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/migrations/src/Command/Phinx/Dump.php (4059B)
setName('dump')
->setDescription('Dumps the current schema of the database to be used while baking a diff')
->setHelp(sprintf(
'%sDumps the current schema of the database to be used while baking a diff%s',
PHP_EOL,
PHP_EOL
))
->addOption('plugin', 'p', InputOption::VALUE_REQUIRED, 'The plugin the file should be created for')
->addOption('connection', 'c', InputOption::VALUE_REQUIRED, 'The datasource connection to use')
->addOption('source', 's', InputOption::VALUE_REQUIRED, 'The folder where migrations are in');
}
/**
* @param \Symfony\Component\Console\Output\OutputInterface $output The output object.
* @return mixed
*/
public function output(?OutputInterface $output = null)
{
if ($output !== null) {
$this->output = $output;
}
return $this->output;
}
/**
* Dumps the current schema to be used when baking a diff
*
* @param \Symfony\Component\Console\Input\InputInterface $input the input object
* @param \Symfony\Component\Console\Output\OutputInterface $output the output object
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->setInput($input);
$this->bootstrap($input, $output);
$this->output($output);
$path = $this->getOperationsPath($input);
/** @var string $connectionName */
$connectionName = $input->getOption('connection') ?: 'default';
$connection = ConnectionManager::get($connectionName);
$collection = $connection->getSchemaCollection();
$options = [
'require-table' => false,
'plugin' => $this->getPlugin($input),
];
$tables = $this->getTablesToBake($collection, $options);
$dump = [];
if ($tables) {
foreach ($tables as $table) {
$schema = $collection->describe($table);
$dump[$table] = $schema;
}
}
$filePath = $path . DS . 'schema-dump-' . $connectionName . '.lock';
$output->writeln(sprintf('
Writing dump file `%s`...', $filePath));
if (file_put_contents($filePath, serialize($dump))) {
$output->writeln(sprintf('
Dump file `%s` was successfully written', $filePath));
return BaseCommand::CODE_SUCCESS;
}
$output->writeln(sprintf(
'
An error occurred while writing dump file `%s`',
$filePath
));
return BaseCommand::CODE_ERROR;
}
}