public function migrationGenerateCommand($diffAgainstCurrent = true, $filterExpression = null)
{
// "driver" is used only for Doctrine, thus we (mis-)use it here
// additionally, when no host is set, skip this step, assuming no DB is needed
if (!$this->isDatabaseConfigured()) {
$this->outputLine('Doctrine migration generation has been SKIPPED, the driver and host backend options are not set in /Configuration/Settings.yaml.');
$this->quit(1);
}
// use default filter expression from settings
if ($filterExpression === null) {
$ignoredTables = array_keys(array_filter($this->settings['doctrine']['migrations']['ignoredTables']));
if ($ignoredTables !== array()) {
$filterExpression = sprintf('/^(?!%s$).*$/xs', implode('$|', $ignoredTables));
}
}
list($status, $migrationClassPathAndFilename) = $this->doctrineService->generateMigration($diffAgainstCurrent, $filterExpression);
$this->outputLine('<info>%s</info>', [$status]);
$this->outputLine();
if ($migrationClassPathAndFilename) {
$choices = ['Don\'t Move'];
$packages = [null];
/** @var Package $package */
foreach ($this->packageManager->getAvailablePackages() as $package) {
$type = $package->getComposerManifest('type');
if ($type === null || strpos($type, 'typo3-') !== 0 && strpos($type, 'neos-') !== 0) {
continue;
}
$choices[] = $package->getPackageKey();
$packages[] = $package;
}
$selectedPackageIndex = (int) $this->output->select('Do you want to move the migration to one of these packages?', $choices, 0);
$this->outputLine();
if ($selectedPackageIndex !== 0) {
/** @var Package $selectedPackage */
$selectedPackage = $packages[$selectedPackageIndex];
$targetPathAndFilename = Files::concatenatePaths([$selectedPackage->getPackagePath(), 'Migrations', $this->doctrineService->getDatabasePlatformName(), basename($migrationClassPathAndFilename)]);
Files::createDirectoryRecursively(dirname($targetPathAndFilename));
rename($migrationClassPathAndFilename, $targetPathAndFilename);
$this->outputLine('The migration was moved to: <comment>%s</comment>', [substr($targetPathAndFilename, strlen(FLOW_PATH_PACKAGES))]);
$this->outputLine();
$this->outputLine('Next Steps:');
} else {
$this->outputLine('Next Steps:');
$this->outputLine(sprintf('- Move <comment>%s</comment> to YourPackage/<comment>Migrations/%s/</comment>', $migrationClassPathAndFilename, $this->doctrineService->getDatabasePlatformName()));
}
$this->outputLine('- Review and adjust the generated migration.');
$this->outputLine('- (optional) execute the migration using <comment>%s doctrine:migrate</comment>', [$this->getFlowInvocationString()]);
}
}