/** * Apply the given migration to the package and commit the result. * * @param string $packageKey * @param array $packageData * @param AbstractMigration $migration * @return void * @throws \RuntimeException */ protected function migratePackage($packageKey, array $packageData, AbstractMigration $migration) { if (Git::isWorkingCopyClean($packageData['path'])) { echo ' Migrating ' . $packageKey . PHP_EOL; if (Git::hasMigrationApplied($packageData['path'], $migration->getIdentifier())) { echo ' Skipping ' . $packageKey . ', the migration is already applied.' . PHP_EOL; } else { try { $migration->execute($packageData); echo Git::commitMigration($packageData['path'], $migration->getIdentifier()); } catch (\Exeption $exception) { throw new \RuntimeException('Applying migration "' . $migration->getIdentifier() . '" to "' . $packageKey . '" failed.', 0, $exception); } } } else { echo ' Skipping ' . $packageKey . ', the working copy is dirty.' . PHP_EOL; } }
require __DIR__ . '/Migrations/Git.php'; define('FLOW3_SAPITYPE', PHP_SAPI === 'cli' ? 'CLI' : 'Web'); if (FLOW3_SAPITYPE !== 'CLI') { exit('The migrate tool can only be run from the command line (with a CLI PHP binary).'); } define('FLOW3_PATH_FLOW3', str_replace('//', '/', str_replace('\\', '/', realpath(__DIR__ . '/../') . '/'))); define('FLOW3_PATH_ROOT', str_replace('//', '/', str_replace('\\', '/', realpath(__DIR__ . '/../../../../') . '/'))); define('FLOW3_PATH_WEB', FLOW3_PATH_ROOT . 'Web/'); define('FLOW3_PATH_CONFIGURATION', FLOW3_PATH_ROOT . 'Configuration/'); define('FLOW3_PATH_DATA', FLOW3_PATH_ROOT . 'Data/'); if (flagIsSet('packages-path')) { define('FLOW3_PATH_PACKAGES', getFlagValue('packages-path')); } else { define('FLOW3_PATH_PACKAGES', FLOW3_PATH_ROOT . 'Packages/'); } if (\TYPO3\FLOW3\Core\Migrations\Git::isGitAvailable() === FALSE) { echo 'No executable git binary found, exiting.'; exit(255); } $migrationsManager = new \TYPO3\FLOW3\Core\Migrations\Manager(); if (flagIsSet('status')) { $status = $migrationsManager->getStatus(); $output = PHP_EOL . ' == Migration status' . PHP_EOL; foreach ($status as $packageKey => $migrations) { $output .= PHP_EOL . ' == for ' . $packageKey . PHP_EOL; foreach ($migrations as $versionNumber => $migration) { $status = $migration['state'] === \TYPO3\FLOW3\Core\Migrations\Manager::STATE_MIGRATED ? 'migrated' : 'not migrated'; $output .= ' >> ' . formatVersion($versionNumber) . ' (' . $migration['source'] . ')' . str_repeat(' ', 30 - strlen($status)) . $status . PHP_EOL; } } echo $output;