@@ -43,123 +43,123 @@ |
||
| 43 | 43 | $application->add(new OC\Core\Command\App\CheckCode()); |
| 44 | 44 | $application->add(new OC\Core\Command\L10n\CreateJs()); |
| 45 | 45 | $application->add(new \OC\Core\Command\Integrity\SignApp( |
| 46 | - \OC::$server->getIntegrityCodeChecker(), |
|
| 47 | - new \OC\IntegrityCheck\Helpers\FileAccessHelper(), |
|
| 48 | - \OC::$server->getURLGenerator() |
|
| 46 | + \OC::$server->getIntegrityCodeChecker(), |
|
| 47 | + new \OC\IntegrityCheck\Helpers\FileAccessHelper(), |
|
| 48 | + \OC::$server->getURLGenerator() |
|
| 49 | 49 | )); |
| 50 | 50 | $application->add(new \OC\Core\Command\Integrity\SignCore( |
| 51 | - \OC::$server->getIntegrityCodeChecker(), |
|
| 52 | - new \OC\IntegrityCheck\Helpers\FileAccessHelper() |
|
| 51 | + \OC::$server->getIntegrityCodeChecker(), |
|
| 52 | + new \OC\IntegrityCheck\Helpers\FileAccessHelper() |
|
| 53 | 53 | )); |
| 54 | 54 | $application->add(new \OC\Core\Command\Integrity\CheckApp( |
| 55 | - \OC::$server->getIntegrityCodeChecker() |
|
| 55 | + \OC::$server->getIntegrityCodeChecker() |
|
| 56 | 56 | )); |
| 57 | 57 | $application->add(new \OC\Core\Command\Integrity\CheckCore( |
| 58 | - \OC::$server->getIntegrityCodeChecker() |
|
| 58 | + \OC::$server->getIntegrityCodeChecker() |
|
| 59 | 59 | )); |
| 60 | 60 | |
| 61 | 61 | |
| 62 | 62 | if (\OC::$server->getConfig()->getSystemValue('installed', false)) { |
| 63 | - $application->add(new OC\Core\Command\App\Disable(\OC::$server->getAppManager())); |
|
| 64 | - $application->add(new OC\Core\Command\App\Enable(\OC::$server->getAppManager())); |
|
| 65 | - $application->add(new OC\Core\Command\App\Install()); |
|
| 66 | - $application->add(new OC\Core\Command\App\GetPath()); |
|
| 67 | - $application->add(new OC\Core\Command\App\ListApps(\OC::$server->getAppManager())); |
|
| 63 | + $application->add(new OC\Core\Command\App\Disable(\OC::$server->getAppManager())); |
|
| 64 | + $application->add(new OC\Core\Command\App\Enable(\OC::$server->getAppManager())); |
|
| 65 | + $application->add(new OC\Core\Command\App\Install()); |
|
| 66 | + $application->add(new OC\Core\Command\App\GetPath()); |
|
| 67 | + $application->add(new OC\Core\Command\App\ListApps(\OC::$server->getAppManager())); |
|
| 68 | 68 | |
| 69 | - $application->add(new OC\Core\Command\TwoFactorAuth\Enable( |
|
| 70 | - \OC::$server->getTwoFactorAuthManager(), \OC::$server->getUserManager() |
|
| 71 | - )); |
|
| 72 | - $application->add(new OC\Core\Command\TwoFactorAuth\Disable( |
|
| 73 | - \OC::$server->getTwoFactorAuthManager(), \OC::$server->getUserManager() |
|
| 74 | - )); |
|
| 69 | + $application->add(new OC\Core\Command\TwoFactorAuth\Enable( |
|
| 70 | + \OC::$server->getTwoFactorAuthManager(), \OC::$server->getUserManager() |
|
| 71 | + )); |
|
| 72 | + $application->add(new OC\Core\Command\TwoFactorAuth\Disable( |
|
| 73 | + \OC::$server->getTwoFactorAuthManager(), \OC::$server->getUserManager() |
|
| 74 | + )); |
|
| 75 | 75 | |
| 76 | - $application->add(new OC\Core\Command\Background\Cron(\OC::$server->getConfig())); |
|
| 77 | - $application->add(new OC\Core\Command\Background\WebCron(\OC::$server->getConfig())); |
|
| 78 | - $application->add(new OC\Core\Command\Background\Ajax(\OC::$server->getConfig())); |
|
| 76 | + $application->add(new OC\Core\Command\Background\Cron(\OC::$server->getConfig())); |
|
| 77 | + $application->add(new OC\Core\Command\Background\WebCron(\OC::$server->getConfig())); |
|
| 78 | + $application->add(new OC\Core\Command\Background\Ajax(\OC::$server->getConfig())); |
|
| 79 | 79 | |
| 80 | - $application->add(new OC\Core\Command\Config\App\DeleteConfig(\OC::$server->getConfig())); |
|
| 81 | - $application->add(new OC\Core\Command\Config\App\GetConfig(\OC::$server->getConfig())); |
|
| 82 | - $application->add(new OC\Core\Command\Config\App\SetConfig(\OC::$server->getConfig())); |
|
| 83 | - $application->add(new OC\Core\Command\Config\Import(\OC::$server->getConfig())); |
|
| 84 | - $application->add(new OC\Core\Command\Config\ListConfigs(\OC::$server->getSystemConfig(), \OC::$server->getAppConfig())); |
|
| 85 | - $application->add(new OC\Core\Command\Config\System\DeleteConfig(\OC::$server->getSystemConfig())); |
|
| 86 | - $application->add(new OC\Core\Command\Config\System\GetConfig(\OC::$server->getSystemConfig())); |
|
| 87 | - $application->add(new OC\Core\Command\Config\System\SetConfig(\OC::$server->getSystemConfig())); |
|
| 80 | + $application->add(new OC\Core\Command\Config\App\DeleteConfig(\OC::$server->getConfig())); |
|
| 81 | + $application->add(new OC\Core\Command\Config\App\GetConfig(\OC::$server->getConfig())); |
|
| 82 | + $application->add(new OC\Core\Command\Config\App\SetConfig(\OC::$server->getConfig())); |
|
| 83 | + $application->add(new OC\Core\Command\Config\Import(\OC::$server->getConfig())); |
|
| 84 | + $application->add(new OC\Core\Command\Config\ListConfigs(\OC::$server->getSystemConfig(), \OC::$server->getAppConfig())); |
|
| 85 | + $application->add(new OC\Core\Command\Config\System\DeleteConfig(\OC::$server->getSystemConfig())); |
|
| 86 | + $application->add(new OC\Core\Command\Config\System\GetConfig(\OC::$server->getSystemConfig())); |
|
| 87 | + $application->add(new OC\Core\Command\Config\System\SetConfig(\OC::$server->getSystemConfig())); |
|
| 88 | 88 | |
| 89 | - $application->add(new OC\Core\Command\Db\ConvertType(\OC::$server->getConfig(), new \OC\DB\ConnectionFactory(\OC::$server->getSystemConfig()))); |
|
| 90 | - $application->add(new OC\Core\Command\Db\ConvertMysqlToMB4(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection(), \OC::$server->getURLGenerator(), \OC::$server->getLogger())); |
|
| 91 | - $application->add(new OC\Core\Command\Db\ConvertFilecacheBigInt(\OC::$server->getDatabaseConnection())); |
|
| 92 | - $application->add(new OC\Core\Command\Db\AddMissingIndices(\OC::$server->getDatabaseConnection())); |
|
| 93 | - $application->add(new OC\Core\Command\Db\Migrations\StatusCommand(\OC::$server->getDatabaseConnection())); |
|
| 94 | - $application->add(new OC\Core\Command\Db\Migrations\MigrateCommand(\OC::$server->getDatabaseConnection())); |
|
| 95 | - $application->add(new OC\Core\Command\Db\Migrations\GenerateCommand(\OC::$server->getDatabaseConnection(), \OC::$server->getAppManager())); |
|
| 96 | - $application->add(new OC\Core\Command\Db\Migrations\GenerateFromSchemaFileCommand(\OC::$server->getConfig(), \OC::$server->getAppManager(), \OC::$server->getDatabaseConnection())); |
|
| 97 | - $application->add(new OC\Core\Command\Db\Migrations\ExecuteCommand(\OC::$server->getDatabaseConnection(), \OC::$server->getAppManager(), \OC::$server->getConfig())); |
|
| 89 | + $application->add(new OC\Core\Command\Db\ConvertType(\OC::$server->getConfig(), new \OC\DB\ConnectionFactory(\OC::$server->getSystemConfig()))); |
|
| 90 | + $application->add(new OC\Core\Command\Db\ConvertMysqlToMB4(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection(), \OC::$server->getURLGenerator(), \OC::$server->getLogger())); |
|
| 91 | + $application->add(new OC\Core\Command\Db\ConvertFilecacheBigInt(\OC::$server->getDatabaseConnection())); |
|
| 92 | + $application->add(new OC\Core\Command\Db\AddMissingIndices(\OC::$server->getDatabaseConnection())); |
|
| 93 | + $application->add(new OC\Core\Command\Db\Migrations\StatusCommand(\OC::$server->getDatabaseConnection())); |
|
| 94 | + $application->add(new OC\Core\Command\Db\Migrations\MigrateCommand(\OC::$server->getDatabaseConnection())); |
|
| 95 | + $application->add(new OC\Core\Command\Db\Migrations\GenerateCommand(\OC::$server->getDatabaseConnection(), \OC::$server->getAppManager())); |
|
| 96 | + $application->add(new OC\Core\Command\Db\Migrations\GenerateFromSchemaFileCommand(\OC::$server->getConfig(), \OC::$server->getAppManager(), \OC::$server->getDatabaseConnection())); |
|
| 97 | + $application->add(new OC\Core\Command\Db\Migrations\ExecuteCommand(\OC::$server->getDatabaseConnection(), \OC::$server->getAppManager(), \OC::$server->getConfig())); |
|
| 98 | 98 | |
| 99 | - $application->add(new OC\Core\Command\Encryption\Disable(\OC::$server->getConfig())); |
|
| 100 | - $application->add(new OC\Core\Command\Encryption\Enable(\OC::$server->getConfig(), \OC::$server->getEncryptionManager())); |
|
| 101 | - $application->add(new OC\Core\Command\Encryption\ListModules(\OC::$server->getEncryptionManager())); |
|
| 102 | - $application->add(new OC\Core\Command\Encryption\SetDefaultModule(\OC::$server->getEncryptionManager())); |
|
| 103 | - $application->add(new OC\Core\Command\Encryption\Status(\OC::$server->getEncryptionManager())); |
|
| 104 | - $application->add(new OC\Core\Command\Encryption\EncryptAll(\OC::$server->getEncryptionManager(), \OC::$server->getAppManager(), \OC::$server->getConfig(), new \Symfony\Component\Console\Helper\QuestionHelper())); |
|
| 105 | - $application->add(new OC\Core\Command\Encryption\DecryptAll( |
|
| 106 | - \OC::$server->getEncryptionManager(), |
|
| 107 | - \OC::$server->getAppManager(), |
|
| 108 | - \OC::$server->getConfig(), |
|
| 109 | - new \OC\Encryption\DecryptAll(\OC::$server->getEncryptionManager(), \OC::$server->getUserManager(), new \OC\Files\View()), |
|
| 110 | - new \Symfony\Component\Console\Helper\QuestionHelper()) |
|
| 111 | - ); |
|
| 99 | + $application->add(new OC\Core\Command\Encryption\Disable(\OC::$server->getConfig())); |
|
| 100 | + $application->add(new OC\Core\Command\Encryption\Enable(\OC::$server->getConfig(), \OC::$server->getEncryptionManager())); |
|
| 101 | + $application->add(new OC\Core\Command\Encryption\ListModules(\OC::$server->getEncryptionManager())); |
|
| 102 | + $application->add(new OC\Core\Command\Encryption\SetDefaultModule(\OC::$server->getEncryptionManager())); |
|
| 103 | + $application->add(new OC\Core\Command\Encryption\Status(\OC::$server->getEncryptionManager())); |
|
| 104 | + $application->add(new OC\Core\Command\Encryption\EncryptAll(\OC::$server->getEncryptionManager(), \OC::$server->getAppManager(), \OC::$server->getConfig(), new \Symfony\Component\Console\Helper\QuestionHelper())); |
|
| 105 | + $application->add(new OC\Core\Command\Encryption\DecryptAll( |
|
| 106 | + \OC::$server->getEncryptionManager(), |
|
| 107 | + \OC::$server->getAppManager(), |
|
| 108 | + \OC::$server->getConfig(), |
|
| 109 | + new \OC\Encryption\DecryptAll(\OC::$server->getEncryptionManager(), \OC::$server->getUserManager(), new \OC\Files\View()), |
|
| 110 | + new \Symfony\Component\Console\Helper\QuestionHelper()) |
|
| 111 | + ); |
|
| 112 | 112 | |
| 113 | - $application->add(new OC\Core\Command\Log\Manage(\OC::$server->getConfig())); |
|
| 114 | - $application->add(new OC\Core\Command\Log\File(\OC::$server->getConfig())); |
|
| 113 | + $application->add(new OC\Core\Command\Log\Manage(\OC::$server->getConfig())); |
|
| 114 | + $application->add(new OC\Core\Command\Log\File(\OC::$server->getConfig())); |
|
| 115 | 115 | |
| 116 | - $view = new \OC\Files\View(); |
|
| 117 | - $util = new \OC\Encryption\Util( |
|
| 118 | - $view, |
|
| 119 | - \OC::$server->getUserManager(), |
|
| 120 | - \OC::$server->getGroupManager(), |
|
| 121 | - \OC::$server->getConfig() |
|
| 122 | - ); |
|
| 123 | - $application->add(new OC\Core\Command\Encryption\ChangeKeyStorageRoot( |
|
| 124 | - $view, |
|
| 125 | - \OC::$server->getUserManager(), |
|
| 126 | - \OC::$server->getConfig(), |
|
| 127 | - $util, |
|
| 128 | - new \Symfony\Component\Console\Helper\QuestionHelper() |
|
| 129 | - ) |
|
| 130 | - ); |
|
| 131 | - $application->add(new OC\Core\Command\Encryption\ShowKeyStorageRoot($util)); |
|
| 116 | + $view = new \OC\Files\View(); |
|
| 117 | + $util = new \OC\Encryption\Util( |
|
| 118 | + $view, |
|
| 119 | + \OC::$server->getUserManager(), |
|
| 120 | + \OC::$server->getGroupManager(), |
|
| 121 | + \OC::$server->getConfig() |
|
| 122 | + ); |
|
| 123 | + $application->add(new OC\Core\Command\Encryption\ChangeKeyStorageRoot( |
|
| 124 | + $view, |
|
| 125 | + \OC::$server->getUserManager(), |
|
| 126 | + \OC::$server->getConfig(), |
|
| 127 | + $util, |
|
| 128 | + new \Symfony\Component\Console\Helper\QuestionHelper() |
|
| 129 | + ) |
|
| 130 | + ); |
|
| 131 | + $application->add(new OC\Core\Command\Encryption\ShowKeyStorageRoot($util)); |
|
| 132 | 132 | |
| 133 | - $application->add(new OC\Core\Command\Maintenance\DataFingerprint(\OC::$server->getConfig(), new \OC\AppFramework\Utility\TimeFactory())); |
|
| 134 | - $application->add(new OC\Core\Command\Maintenance\Mimetype\UpdateDB(\OC::$server->getMimeTypeDetector(), \OC::$server->getMimeTypeLoader())); |
|
| 135 | - $application->add(new OC\Core\Command\Maintenance\Mimetype\UpdateJS(\OC::$server->getMimeTypeDetector())); |
|
| 136 | - $application->add(new OC\Core\Command\Maintenance\Mode(\OC::$server->getConfig())); |
|
| 137 | - $application->add(new OC\Core\Command\Maintenance\UpdateHtaccess()); |
|
| 138 | - $application->add(new OC\Core\Command\Maintenance\UpdateTheme(\OC::$server->getMimeTypeDetector(), \OC::$server->getMemCacheFactory())); |
|
| 133 | + $application->add(new OC\Core\Command\Maintenance\DataFingerprint(\OC::$server->getConfig(), new \OC\AppFramework\Utility\TimeFactory())); |
|
| 134 | + $application->add(new OC\Core\Command\Maintenance\Mimetype\UpdateDB(\OC::$server->getMimeTypeDetector(), \OC::$server->getMimeTypeLoader())); |
|
| 135 | + $application->add(new OC\Core\Command\Maintenance\Mimetype\UpdateJS(\OC::$server->getMimeTypeDetector())); |
|
| 136 | + $application->add(new OC\Core\Command\Maintenance\Mode(\OC::$server->getConfig())); |
|
| 137 | + $application->add(new OC\Core\Command\Maintenance\UpdateHtaccess()); |
|
| 138 | + $application->add(new OC\Core\Command\Maintenance\UpdateTheme(\OC::$server->getMimeTypeDetector(), \OC::$server->getMemCacheFactory())); |
|
| 139 | 139 | |
| 140 | - $application->add(new OC\Core\Command\Upgrade(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->query(\OC\Installer::class))); |
|
| 141 | - $application->add(new OC\Core\Command\Maintenance\Repair( |
|
| 142 | - new \OC\Repair(\OC\Repair::getRepairSteps(), \OC::$server->getEventDispatcher()), \OC::$server->getConfig(), |
|
| 143 | - \OC::$server->getEventDispatcher(), \OC::$server->getAppManager())); |
|
| 140 | + $application->add(new OC\Core\Command\Upgrade(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->query(\OC\Installer::class))); |
|
| 141 | + $application->add(new OC\Core\Command\Maintenance\Repair( |
|
| 142 | + new \OC\Repair(\OC\Repair::getRepairSteps(), \OC::$server->getEventDispatcher()), \OC::$server->getConfig(), |
|
| 143 | + \OC::$server->getEventDispatcher(), \OC::$server->getAppManager())); |
|
| 144 | 144 | |
| 145 | - $application->add(new OC\Core\Command\User\Add(\OC::$server->getUserManager(), \OC::$server->getGroupManager())); |
|
| 146 | - $application->add(new OC\Core\Command\User\Delete(\OC::$server->getUserManager())); |
|
| 147 | - $application->add(new OC\Core\Command\User\Disable(\OC::$server->getUserManager())); |
|
| 148 | - $application->add(new OC\Core\Command\User\Enable(\OC::$server->getUserManager())); |
|
| 149 | - $application->add(new OC\Core\Command\User\LastSeen(\OC::$server->getUserManager())); |
|
| 150 | - $application->add(new OC\Core\Command\User\Report(\OC::$server->getUserManager())); |
|
| 151 | - $application->add(new OC\Core\Command\User\ResetPassword(\OC::$server->getUserManager())); |
|
| 152 | - $application->add(new OC\Core\Command\User\Setting(\OC::$server->getUserManager(), \OC::$server->getConfig(), \OC::$server->getDatabaseConnection())); |
|
| 153 | - $application->add(new OC\Core\Command\User\ListCommand(\OC::$server->getUserManager())); |
|
| 154 | - $application->add(new OC\Core\Command\User\Info(\OC::$server->getUserManager(), \OC::$server->getGroupManager())); |
|
| 145 | + $application->add(new OC\Core\Command\User\Add(\OC::$server->getUserManager(), \OC::$server->getGroupManager())); |
|
| 146 | + $application->add(new OC\Core\Command\User\Delete(\OC::$server->getUserManager())); |
|
| 147 | + $application->add(new OC\Core\Command\User\Disable(\OC::$server->getUserManager())); |
|
| 148 | + $application->add(new OC\Core\Command\User\Enable(\OC::$server->getUserManager())); |
|
| 149 | + $application->add(new OC\Core\Command\User\LastSeen(\OC::$server->getUserManager())); |
|
| 150 | + $application->add(new OC\Core\Command\User\Report(\OC::$server->getUserManager())); |
|
| 151 | + $application->add(new OC\Core\Command\User\ResetPassword(\OC::$server->getUserManager())); |
|
| 152 | + $application->add(new OC\Core\Command\User\Setting(\OC::$server->getUserManager(), \OC::$server->getConfig(), \OC::$server->getDatabaseConnection())); |
|
| 153 | + $application->add(new OC\Core\Command\User\ListCommand(\OC::$server->getUserManager())); |
|
| 154 | + $application->add(new OC\Core\Command\User\Info(\OC::$server->getUserManager(), \OC::$server->getGroupManager())); |
|
| 155 | 155 | |
| 156 | - $application->add(new OC\Core\Command\Group\ListCommand(\OC::$server->getGroupManager())); |
|
| 157 | - $application->add(new OC\Core\Command\Group\AddUser(\OC::$server->getUserManager(), \OC::$server->getGroupManager())); |
|
| 158 | - $application->add(new OC\Core\Command\Group\RemoveUser(\OC::$server->getUserManager(), \OC::$server->getGroupManager())); |
|
| 156 | + $application->add(new OC\Core\Command\Group\ListCommand(\OC::$server->getGroupManager())); |
|
| 157 | + $application->add(new OC\Core\Command\Group\AddUser(\OC::$server->getUserManager(), \OC::$server->getGroupManager())); |
|
| 158 | + $application->add(new OC\Core\Command\Group\RemoveUser(\OC::$server->getUserManager(), \OC::$server->getGroupManager())); |
|
| 159 | 159 | |
| 160 | - $application->add(new OC\Core\Command\Security\ListCertificates(\OC::$server->getCertificateManager(null), \OC::$server->getL10N('core'))); |
|
| 161 | - $application->add(new OC\Core\Command\Security\ImportCertificate(\OC::$server->getCertificateManager(null))); |
|
| 162 | - $application->add(new OC\Core\Command\Security\RemoveCertificate(\OC::$server->getCertificateManager(null))); |
|
| 160 | + $application->add(new OC\Core\Command\Security\ListCertificates(\OC::$server->getCertificateManager(null), \OC::$server->getL10N('core'))); |
|
| 161 | + $application->add(new OC\Core\Command\Security\ImportCertificate(\OC::$server->getCertificateManager(null))); |
|
| 162 | + $application->add(new OC\Core\Command\Security\RemoveCertificate(\OC::$server->getCertificateManager(null))); |
|
| 163 | 163 | } else { |
| 164 | - $application->add(new OC\Core\Command\Maintenance\Install(\OC::$server->getSystemConfig())); |
|
| 164 | + $application->add(new OC\Core\Command\Maintenance\Install(\OC::$server->getSystemConfig())); |
|
| 165 | 165 | } |
@@ -35,66 +35,66 @@ |
||
| 35 | 35 | |
| 36 | 36 | class MigrateCommand extends Command implements CompletionAwareInterface { |
| 37 | 37 | |
| 38 | - /** @var IDBConnection */ |
|
| 39 | - private $connection; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @param IDBConnection $connection |
|
| 43 | - */ |
|
| 44 | - public function __construct(IDBConnection $connection) { |
|
| 45 | - $this->connection = $connection; |
|
| 46 | - parent::__construct(); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - protected function configure() { |
|
| 50 | - $this |
|
| 51 | - ->setName('migrations:migrate') |
|
| 52 | - ->setDescription('Execute a migration to a specified version or the latest available version.') |
|
| 53 | - ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on') |
|
| 54 | - ->addArgument('version', InputArgument::OPTIONAL, 'The version number (YYYYMMDDHHMMSS) or alias (first, prev, next, latest) to migrate to.', 'latest'); |
|
| 55 | - |
|
| 56 | - parent::configure(); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - public function execute(InputInterface $input, OutputInterface $output) { |
|
| 60 | - $appName = $input->getArgument('app'); |
|
| 61 | - $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
| 62 | - $version = $input->getArgument('version'); |
|
| 63 | - |
|
| 64 | - $ms->migrate($version); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @param string $optionName |
|
| 69 | - * @param CompletionContext $context |
|
| 70 | - * @return string[] |
|
| 71 | - */ |
|
| 72 | - public function completeOptionValues($optionName, CompletionContext $context) { |
|
| 73 | - return []; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @param string $argumentName |
|
| 78 | - * @param CompletionContext $context |
|
| 79 | - * @return string[] |
|
| 80 | - */ |
|
| 81 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
| 82 | - if ($argumentName === 'app') { |
|
| 83 | - $allApps = \OC_App::getAllApps(); |
|
| 84 | - return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - if ($argumentName === 'version') { |
|
| 88 | - $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
|
| 89 | - |
|
| 90 | - $ms = new MigrationService($appName, $this->connection); |
|
| 91 | - $migrations = $ms->getAvailableVersions(); |
|
| 92 | - |
|
| 93 | - array_unshift($migrations, 'next', 'latest'); |
|
| 94 | - return $migrations; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - return []; |
|
| 98 | - } |
|
| 38 | + /** @var IDBConnection */ |
|
| 39 | + private $connection; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @param IDBConnection $connection |
|
| 43 | + */ |
|
| 44 | + public function __construct(IDBConnection $connection) { |
|
| 45 | + $this->connection = $connection; |
|
| 46 | + parent::__construct(); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + protected function configure() { |
|
| 50 | + $this |
|
| 51 | + ->setName('migrations:migrate') |
|
| 52 | + ->setDescription('Execute a migration to a specified version or the latest available version.') |
|
| 53 | + ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on') |
|
| 54 | + ->addArgument('version', InputArgument::OPTIONAL, 'The version number (YYYYMMDDHHMMSS) or alias (first, prev, next, latest) to migrate to.', 'latest'); |
|
| 55 | + |
|
| 56 | + parent::configure(); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + public function execute(InputInterface $input, OutputInterface $output) { |
|
| 60 | + $appName = $input->getArgument('app'); |
|
| 61 | + $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
| 62 | + $version = $input->getArgument('version'); |
|
| 63 | + |
|
| 64 | + $ms->migrate($version); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @param string $optionName |
|
| 69 | + * @param CompletionContext $context |
|
| 70 | + * @return string[] |
|
| 71 | + */ |
|
| 72 | + public function completeOptionValues($optionName, CompletionContext $context) { |
|
| 73 | + return []; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @param string $argumentName |
|
| 78 | + * @param CompletionContext $context |
|
| 79 | + * @return string[] |
|
| 80 | + */ |
|
| 81 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
| 82 | + if ($argumentName === 'app') { |
|
| 83 | + $allApps = \OC_App::getAllApps(); |
|
| 84 | + return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + if ($argumentName === 'version') { |
|
| 88 | + $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
|
| 89 | + |
|
| 90 | + $ms = new MigrationService($appName, $this->connection); |
|
| 91 | + $migrations = $ms->getAvailableVersions(); |
|
| 92 | + |
|
| 93 | + array_unshift($migrations, 'next', 'latest'); |
|
| 94 | + return $migrations; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + return []; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | 100 | } |
@@ -36,166 +36,166 @@ |
||
| 36 | 36 | |
| 37 | 37 | class GenerateFromSchemaFileCommand extends GenerateCommand { |
| 38 | 38 | |
| 39 | - /** @var IConfig */ |
|
| 40 | - protected $config; |
|
| 39 | + /** @var IConfig */ |
|
| 40 | + protected $config; |
|
| 41 | 41 | |
| 42 | - public function __construct(IConfig $config, IAppManager $appManager, IDBConnection $connection) { |
|
| 43 | - parent::__construct($connection, $appManager); |
|
| 44 | - $this->config = $config; |
|
| 45 | - } |
|
| 42 | + public function __construct(IConfig $config, IAppManager $appManager, IDBConnection $connection) { |
|
| 43 | + parent::__construct($connection, $appManager); |
|
| 44 | + $this->config = $config; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | 47 | |
| 48 | - protected function configure() { |
|
| 49 | - parent::configure(); |
|
| 48 | + protected function configure() { |
|
| 49 | + parent::configure(); |
|
| 50 | 50 | |
| 51 | - $this->setName('migrations:generate-from-schema'); |
|
| 52 | - } |
|
| 51 | + $this->setName('migrations:generate-from-schema'); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - public function execute(InputInterface $input, OutputInterface $output) { |
|
| 55 | - $appName = $input->getArgument('app'); |
|
| 56 | - $version = $input->getArgument('version'); |
|
| 54 | + public function execute(InputInterface $input, OutputInterface $output) { |
|
| 55 | + $appName = $input->getArgument('app'); |
|
| 56 | + $version = $input->getArgument('version'); |
|
| 57 | 57 | |
| 58 | - if (!preg_match('/^\d{1,16}$/',$version)) { |
|
| 59 | - $output->writeln('<error>The given version is invalid. Only 0-9 are allowed (max. 16 digits)</error>'); |
|
| 60 | - return 1; |
|
| 61 | - } |
|
| 58 | + if (!preg_match('/^\d{1,16}$/',$version)) { |
|
| 59 | + $output->writeln('<error>The given version is invalid. Only 0-9 are allowed (max. 16 digits)</error>'); |
|
| 60 | + return 1; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - $schemaFile = $this->appManager->getAppPath($appName) . '/appinfo/database.xml'; |
|
| 64 | - if (!file_exists($schemaFile)) { |
|
| 65 | - $output->writeln('<error>App ' . $appName . ' does not have a database.xml file</error>'); |
|
| 66 | - return 2; |
|
| 67 | - } |
|
| 63 | + $schemaFile = $this->appManager->getAppPath($appName) . '/appinfo/database.xml'; |
|
| 64 | + if (!file_exists($schemaFile)) { |
|
| 65 | + $output->writeln('<error>App ' . $appName . ' does not have a database.xml file</error>'); |
|
| 66 | + return 2; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - $reader = new MDB2SchemaReader($this->config, $this->connection->getDatabasePlatform()); |
|
| 70 | - $schema = new Schema(); |
|
| 71 | - $reader->loadSchemaFromFile($schemaFile, $schema); |
|
| 69 | + $reader = new MDB2SchemaReader($this->config, $this->connection->getDatabasePlatform()); |
|
| 70 | + $schema = new Schema(); |
|
| 71 | + $reader->loadSchemaFromFile($schemaFile, $schema); |
|
| 72 | 72 | |
| 73 | - $schemaBody = $this->schemaToMigration($schema); |
|
| 73 | + $schemaBody = $this->schemaToMigration($schema); |
|
| 74 | 74 | |
| 75 | - $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
| 75 | + $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
| 76 | 76 | |
| 77 | - $date = date('YmdHis'); |
|
| 78 | - $path = $this->generateMigration($ms, 'Version' . $version . 'Date' . $date, $schemaBody); |
|
| 77 | + $date = date('YmdHis'); |
|
| 78 | + $path = $this->generateMigration($ms, 'Version' . $version . 'Date' . $date, $schemaBody); |
|
| 79 | 79 | |
| 80 | - $output->writeln("New migration class has been generated to <info>$path</info>"); |
|
| 81 | - return 0; |
|
| 82 | - } |
|
| 80 | + $output->writeln("New migration class has been generated to <info>$path</info>"); |
|
| 81 | + return 0; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * @param Schema $schema |
|
| 86 | - * @return string |
|
| 87 | - */ |
|
| 88 | - protected function schemaToMigration(Schema $schema) { |
|
| 89 | - $content = <<<'EOT' |
|
| 84 | + /** |
|
| 85 | + * @param Schema $schema |
|
| 86 | + * @return string |
|
| 87 | + */ |
|
| 88 | + protected function schemaToMigration(Schema $schema) { |
|
| 89 | + $content = <<<'EOT' |
|
| 90 | 90 | /** @var ISchemaWrapper $schema */ |
| 91 | 91 | $schema = $schemaClosure(); |
| 92 | 92 | |
| 93 | 93 | EOT; |
| 94 | 94 | |
| 95 | - foreach ($schema->getTables() as $table) { |
|
| 96 | - $content .= str_replace('{{table-name}}', substr($table->getName(), 3), <<<'EOT' |
|
| 95 | + foreach ($schema->getTables() as $table) { |
|
| 96 | + $content .= str_replace('{{table-name}}', substr($table->getName(), 3), <<<'EOT' |
|
| 97 | 97 | |
| 98 | 98 | if (!$schema->hasTable('{{table-name}}')) { |
| 99 | 99 | $table = $schema->createTable('{{table-name}}'); |
| 100 | 100 | |
| 101 | 101 | EOT |
| 102 | - ); |
|
| 102 | + ); |
|
| 103 | 103 | |
| 104 | - foreach ($table->getColumns() as $column) { |
|
| 105 | - $content .= str_replace(['{{name}}', '{{type}}'], [$column->getName(), $column->getType()->getName()], <<<'EOT' |
|
| 104 | + foreach ($table->getColumns() as $column) { |
|
| 105 | + $content .= str_replace(['{{name}}', '{{type}}'], [$column->getName(), $column->getType()->getName()], <<<'EOT' |
|
| 106 | 106 | $table->addColumn('{{name}}', '{{type}}', [ |
| 107 | 107 | |
| 108 | 108 | EOT |
| 109 | - ); |
|
| 110 | - if ($column->getAutoincrement()) { |
|
| 111 | - $content .= <<<'EOT' |
|
| 109 | + ); |
|
| 110 | + if ($column->getAutoincrement()) { |
|
| 111 | + $content .= <<<'EOT' |
|
| 112 | 112 | 'autoincrement' => true, |
| 113 | 113 | |
| 114 | 114 | EOT; |
| 115 | - } |
|
| 116 | - $content .= str_replace('{{notnull}}', $column->getNotnull() ? 'true' : 'false', <<<'EOT' |
|
| 115 | + } |
|
| 116 | + $content .= str_replace('{{notnull}}', $column->getNotnull() ? 'true' : 'false', <<<'EOT' |
|
| 117 | 117 | 'notnull' => {{notnull}}, |
| 118 | 118 | |
| 119 | 119 | EOT |
| 120 | - ); |
|
| 121 | - if ($column->getLength() !== null) { |
|
| 122 | - $content .= str_replace('{{length}}', $column->getLength(), <<<'EOT' |
|
| 120 | + ); |
|
| 121 | + if ($column->getLength() !== null) { |
|
| 122 | + $content .= str_replace('{{length}}', $column->getLength(), <<<'EOT' |
|
| 123 | 123 | 'length' => {{length}}, |
| 124 | 124 | |
| 125 | 125 | EOT |
| 126 | - ); |
|
| 127 | - } |
|
| 128 | - $default = $column->getDefault(); |
|
| 129 | - if ($default !== null) { |
|
| 130 | - $default = is_numeric($default) ? $default : "'$default'"; |
|
| 131 | - $content .= str_replace('{{default}}', $default, <<<'EOT' |
|
| 126 | + ); |
|
| 127 | + } |
|
| 128 | + $default = $column->getDefault(); |
|
| 129 | + if ($default !== null) { |
|
| 130 | + $default = is_numeric($default) ? $default : "'$default'"; |
|
| 131 | + $content .= str_replace('{{default}}', $default, <<<'EOT' |
|
| 132 | 132 | 'default' => {{default}}, |
| 133 | 133 | |
| 134 | 134 | EOT |
| 135 | - ); |
|
| 136 | - } |
|
| 137 | - if ($column->getUnsigned()) { |
|
| 138 | - $content .= <<<'EOT' |
|
| 135 | + ); |
|
| 136 | + } |
|
| 137 | + if ($column->getUnsigned()) { |
|
| 138 | + $content .= <<<'EOT' |
|
| 139 | 139 | 'unsigned' => true, |
| 140 | 140 | |
| 141 | 141 | EOT; |
| 142 | - } |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - $content .= <<<'EOT' |
|
| 144 | + $content .= <<<'EOT' |
|
| 145 | 145 | ]); |
| 146 | 146 | |
| 147 | 147 | EOT; |
| 148 | - } |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - $content .= <<<'EOT' |
|
| 150 | + $content .= <<<'EOT' |
|
| 151 | 151 | |
| 152 | 152 | EOT; |
| 153 | 153 | |
| 154 | - $primaryKey = $table->getPrimaryKey(); |
|
| 155 | - if ($primaryKey !== null) { |
|
| 156 | - $content .= str_replace('{{columns}}', implode('\', \'', $primaryKey->getUnquotedColumns()), <<<'EOT' |
|
| 154 | + $primaryKey = $table->getPrimaryKey(); |
|
| 155 | + if ($primaryKey !== null) { |
|
| 156 | + $content .= str_replace('{{columns}}', implode('\', \'', $primaryKey->getUnquotedColumns()), <<<'EOT' |
|
| 157 | 157 | $table->setPrimaryKey(['{{columns}}']); |
| 158 | 158 | |
| 159 | 159 | EOT |
| 160 | - ); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - foreach ($table->getIndexes() as $index) { |
|
| 164 | - if ($index->isPrimary()) { |
|
| 165 | - continue; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - if ($index->isUnique()) { |
|
| 169 | - $content .= str_replace( |
|
| 170 | - ['{{columns}}', '{{name}}'], |
|
| 171 | - [implode('\', \'', $index->getUnquotedColumns()), $index->getName()], |
|
| 172 | - <<<'EOT' |
|
| 160 | + ); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + foreach ($table->getIndexes() as $index) { |
|
| 164 | + if ($index->isPrimary()) { |
|
| 165 | + continue; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + if ($index->isUnique()) { |
|
| 169 | + $content .= str_replace( |
|
| 170 | + ['{{columns}}', '{{name}}'], |
|
| 171 | + [implode('\', \'', $index->getUnquotedColumns()), $index->getName()], |
|
| 172 | + <<<'EOT' |
|
| 173 | 173 | $table->addUniqueIndex(['{{columns}}'], '{{name}}'); |
| 174 | 174 | |
| 175 | 175 | EOT |
| 176 | - ); |
|
| 177 | - } else { |
|
| 178 | - $content .= str_replace( |
|
| 179 | - ['{{columns}}', '{{name}}'], |
|
| 180 | - [implode('\', \'', $index->getUnquotedColumns()), $index->getName()], |
|
| 181 | - <<<'EOT' |
|
| 176 | + ); |
|
| 177 | + } else { |
|
| 178 | + $content .= str_replace( |
|
| 179 | + ['{{columns}}', '{{name}}'], |
|
| 180 | + [implode('\', \'', $index->getUnquotedColumns()), $index->getName()], |
|
| 181 | + <<<'EOT' |
|
| 182 | 182 | $table->addIndex(['{{columns}}'], '{{name}}'); |
| 183 | 183 | |
| 184 | 184 | EOT |
| 185 | - ); |
|
| 186 | - } |
|
| 187 | - } |
|
| 185 | + ); |
|
| 186 | + } |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - $content .= <<<'EOT' |
|
| 189 | + $content .= <<<'EOT' |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | EOT; |
| 193 | - } |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | - $content .= <<<'EOT' |
|
| 195 | + $content .= <<<'EOT' |
|
| 196 | 196 | return $schema; |
| 197 | 197 | EOT; |
| 198 | 198 | |
| 199 | - return $content; |
|
| 200 | - } |
|
| 199 | + return $content; |
|
| 200 | + } |
|
| 201 | 201 | } |
@@ -38,95 +38,95 @@ |
||
| 38 | 38 | |
| 39 | 39 | class ExecuteCommand extends Command implements CompletionAwareInterface { |
| 40 | 40 | |
| 41 | - /** @var IDBConnection */ |
|
| 42 | - private $connection; |
|
| 43 | - |
|
| 44 | - /** @var IConfig */ |
|
| 45 | - private $config; |
|
| 46 | - |
|
| 47 | - /** @var IAppManager */ |
|
| 48 | - protected $appManager; |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * ExecuteCommand constructor. |
|
| 52 | - * |
|
| 53 | - * @param IDBConnection $connection |
|
| 54 | - * @param IConfig $config |
|
| 55 | - * @param IAppManager $appManager |
|
| 56 | - */ |
|
| 57 | - public function __construct(IDBConnection $connection, IAppManager $appManager, IConfig $config) { |
|
| 58 | - $this->connection = $connection; |
|
| 59 | - $this->config = $config; |
|
| 60 | - |
|
| 61 | - parent::__construct(); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - protected function configure() { |
|
| 65 | - $this |
|
| 66 | - ->setName('migrations:execute') |
|
| 67 | - ->setDescription('Execute a single migration version manually.') |
|
| 68 | - ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on') |
|
| 69 | - ->addArgument('version', InputArgument::REQUIRED, 'The version to execute.', null); |
|
| 70 | - |
|
| 71 | - parent::configure(); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * @param InputInterface $input |
|
| 76 | - * @param OutputInterface $output |
|
| 77 | - * @return int |
|
| 78 | - */ |
|
| 79 | - public function execute(InputInterface $input, OutputInterface $output) { |
|
| 80 | - $appName = $input->getArgument('app'); |
|
| 81 | - $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
| 82 | - $version = $input->getArgument('version'); |
|
| 83 | - |
|
| 84 | - if ($this->config->getSystemValue('debug', false) === false) { |
|
| 85 | - $olderVersions = $ms->getMigratedVersions(); |
|
| 86 | - $olderVersions[] = '0'; |
|
| 87 | - $olderVersions[] = 'prev'; |
|
| 88 | - if (in_array($version, $olderVersions, true)) { |
|
| 89 | - $output->writeln('<error>Can not go back to previous migration without debug enabled</error>'); |
|
| 90 | - return 1; |
|
| 91 | - } |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - |
|
| 95 | - $ms->executeStep($version); |
|
| 96 | - return 0; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * @param string $optionName |
|
| 101 | - * @param CompletionContext $context |
|
| 102 | - * @return string[] |
|
| 103 | - */ |
|
| 104 | - public function completeOptionValues($optionName, CompletionContext $context) { |
|
| 105 | - return []; |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * @param string $argumentName |
|
| 110 | - * @param CompletionContext $context |
|
| 111 | - * @return string[] |
|
| 112 | - */ |
|
| 113 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
| 114 | - if ($argumentName === 'app') { |
|
| 115 | - $allApps = \OC_App::getAllApps(); |
|
| 116 | - return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - if ($argumentName === 'version') { |
|
| 120 | - $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
|
| 121 | - |
|
| 122 | - $ms = new MigrationService($appName, $this->connection); |
|
| 123 | - $migrations = $ms->getAvailableVersions(); |
|
| 124 | - |
|
| 125 | - array_unshift($migrations, 'next', 'latest'); |
|
| 126 | - return $migrations; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - return []; |
|
| 130 | - } |
|
| 41 | + /** @var IDBConnection */ |
|
| 42 | + private $connection; |
|
| 43 | + |
|
| 44 | + /** @var IConfig */ |
|
| 45 | + private $config; |
|
| 46 | + |
|
| 47 | + /** @var IAppManager */ |
|
| 48 | + protected $appManager; |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * ExecuteCommand constructor. |
|
| 52 | + * |
|
| 53 | + * @param IDBConnection $connection |
|
| 54 | + * @param IConfig $config |
|
| 55 | + * @param IAppManager $appManager |
|
| 56 | + */ |
|
| 57 | + public function __construct(IDBConnection $connection, IAppManager $appManager, IConfig $config) { |
|
| 58 | + $this->connection = $connection; |
|
| 59 | + $this->config = $config; |
|
| 60 | + |
|
| 61 | + parent::__construct(); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + protected function configure() { |
|
| 65 | + $this |
|
| 66 | + ->setName('migrations:execute') |
|
| 67 | + ->setDescription('Execute a single migration version manually.') |
|
| 68 | + ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on') |
|
| 69 | + ->addArgument('version', InputArgument::REQUIRED, 'The version to execute.', null); |
|
| 70 | + |
|
| 71 | + parent::configure(); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * @param InputInterface $input |
|
| 76 | + * @param OutputInterface $output |
|
| 77 | + * @return int |
|
| 78 | + */ |
|
| 79 | + public function execute(InputInterface $input, OutputInterface $output) { |
|
| 80 | + $appName = $input->getArgument('app'); |
|
| 81 | + $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
| 82 | + $version = $input->getArgument('version'); |
|
| 83 | + |
|
| 84 | + if ($this->config->getSystemValue('debug', false) === false) { |
|
| 85 | + $olderVersions = $ms->getMigratedVersions(); |
|
| 86 | + $olderVersions[] = '0'; |
|
| 87 | + $olderVersions[] = 'prev'; |
|
| 88 | + if (in_array($version, $olderVersions, true)) { |
|
| 89 | + $output->writeln('<error>Can not go back to previous migration without debug enabled</error>'); |
|
| 90 | + return 1; |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + |
|
| 95 | + $ms->executeStep($version); |
|
| 96 | + return 0; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * @param string $optionName |
|
| 101 | + * @param CompletionContext $context |
|
| 102 | + * @return string[] |
|
| 103 | + */ |
|
| 104 | + public function completeOptionValues($optionName, CompletionContext $context) { |
|
| 105 | + return []; |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * @param string $argumentName |
|
| 110 | + * @param CompletionContext $context |
|
| 111 | + * @return string[] |
|
| 112 | + */ |
|
| 113 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
| 114 | + if ($argumentName === 'app') { |
|
| 115 | + $allApps = \OC_App::getAllApps(); |
|
| 116 | + return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + if ($argumentName === 'version') { |
|
| 120 | + $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
|
| 121 | + |
|
| 122 | + $ms = new MigrationService($appName, $this->connection); |
|
| 123 | + $migrations = $ms->getAvailableVersions(); |
|
| 124 | + |
|
| 125 | + array_unshift($migrations, 'next', 'latest'); |
|
| 126 | + return $migrations; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + return []; |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | 132 | } |
@@ -34,107 +34,107 @@ |
||
| 34 | 34 | |
| 35 | 35 | class StatusCommand extends Command implements CompletionAwareInterface { |
| 36 | 36 | |
| 37 | - /** @var IDBConnection */ |
|
| 38 | - private $connection; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @param IDBConnection $connection |
|
| 42 | - */ |
|
| 43 | - public function __construct(IDBConnection $connection) { |
|
| 44 | - $this->connection = $connection; |
|
| 45 | - parent::__construct(); |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - protected function configure() { |
|
| 49 | - $this |
|
| 50 | - ->setName('migrations:status') |
|
| 51 | - ->setDescription('View the status of a set of migrations.') |
|
| 52 | - ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on'); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - public function execute(InputInterface $input, OutputInterface $output) { |
|
| 56 | - $appName = $input->getArgument('app'); |
|
| 57 | - $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
| 58 | - |
|
| 59 | - $infos = $this->getMigrationsInfos($ms); |
|
| 60 | - foreach ($infos as $key => $value) { |
|
| 61 | - $output->writeln(" <comment>>></comment> $key: " . str_repeat(' ', 50 - strlen($key)) . $value); |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * @param string $optionName |
|
| 67 | - * @param CompletionContext $context |
|
| 68 | - * @return string[] |
|
| 69 | - */ |
|
| 70 | - public function completeOptionValues($optionName, CompletionContext $context) { |
|
| 71 | - return []; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * @param string $argumentName |
|
| 76 | - * @param CompletionContext $context |
|
| 77 | - * @return string[] |
|
| 78 | - */ |
|
| 79 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
| 80 | - if ($argumentName === 'app') { |
|
| 81 | - $allApps = \OC_App::getAllApps(); |
|
| 82 | - return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
| 83 | - } |
|
| 84 | - return []; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * @param MigrationService $ms |
|
| 89 | - * @return array associative array of human readable info name as key and the actual information as value |
|
| 90 | - */ |
|
| 91 | - public function getMigrationsInfos(MigrationService $ms) { |
|
| 92 | - |
|
| 93 | - $executedMigrations = $ms->getMigratedVersions(); |
|
| 94 | - $availableMigrations = $ms->getAvailableVersions(); |
|
| 95 | - $executedUnavailableMigrations = array_diff($executedMigrations, array_keys($availableMigrations)); |
|
| 96 | - |
|
| 97 | - $numExecutedUnavailableMigrations = count($executedUnavailableMigrations); |
|
| 98 | - $numNewMigrations = count(array_diff(array_keys($availableMigrations), $executedMigrations)); |
|
| 99 | - |
|
| 100 | - $infos = [ |
|
| 101 | - 'App' => $ms->getApp(), |
|
| 102 | - 'Version Table Name' => $ms->getMigrationsTableName(), |
|
| 103 | - 'Migrations Namespace' => $ms->getMigrationsNamespace(), |
|
| 104 | - 'Migrations Directory' => $ms->getMigrationsDirectory(), |
|
| 105 | - 'Previous Version' => $this->getFormattedVersionAlias($ms, 'prev'), |
|
| 106 | - 'Current Version' => $this->getFormattedVersionAlias($ms, 'current'), |
|
| 107 | - 'Next Version' => $this->getFormattedVersionAlias($ms, 'next'), |
|
| 108 | - 'Latest Version' => $this->getFormattedVersionAlias($ms, 'latest'), |
|
| 109 | - 'Executed Migrations' => count($executedMigrations), |
|
| 110 | - 'Executed Unavailable Migrations' => $numExecutedUnavailableMigrations, |
|
| 111 | - 'Available Migrations' => count($availableMigrations), |
|
| 112 | - 'New Migrations' => $numNewMigrations, |
|
| 113 | - ]; |
|
| 114 | - |
|
| 115 | - return $infos; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * @param MigrationService $migrationService |
|
| 120 | - * @param string $alias |
|
| 121 | - * @return mixed|null|string |
|
| 122 | - */ |
|
| 123 | - private function getFormattedVersionAlias(MigrationService $migrationService, $alias) { |
|
| 124 | - $migration = $migrationService->getMigration($alias); |
|
| 125 | - //No version found |
|
| 126 | - if ($migration === null) { |
|
| 127 | - if ($alias === 'next') { |
|
| 128 | - return 'Already at latest migration step'; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - if ($alias === 'prev') { |
|
| 132 | - return 'Already at first migration step'; |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - return $migration; |
|
| 137 | - } |
|
| 37 | + /** @var IDBConnection */ |
|
| 38 | + private $connection; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @param IDBConnection $connection |
|
| 42 | + */ |
|
| 43 | + public function __construct(IDBConnection $connection) { |
|
| 44 | + $this->connection = $connection; |
|
| 45 | + parent::__construct(); |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + protected function configure() { |
|
| 49 | + $this |
|
| 50 | + ->setName('migrations:status') |
|
| 51 | + ->setDescription('View the status of a set of migrations.') |
|
| 52 | + ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on'); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + public function execute(InputInterface $input, OutputInterface $output) { |
|
| 56 | + $appName = $input->getArgument('app'); |
|
| 57 | + $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
| 58 | + |
|
| 59 | + $infos = $this->getMigrationsInfos($ms); |
|
| 60 | + foreach ($infos as $key => $value) { |
|
| 61 | + $output->writeln(" <comment>>></comment> $key: " . str_repeat(' ', 50 - strlen($key)) . $value); |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * @param string $optionName |
|
| 67 | + * @param CompletionContext $context |
|
| 68 | + * @return string[] |
|
| 69 | + */ |
|
| 70 | + public function completeOptionValues($optionName, CompletionContext $context) { |
|
| 71 | + return []; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * @param string $argumentName |
|
| 76 | + * @param CompletionContext $context |
|
| 77 | + * @return string[] |
|
| 78 | + */ |
|
| 79 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
| 80 | + if ($argumentName === 'app') { |
|
| 81 | + $allApps = \OC_App::getAllApps(); |
|
| 82 | + return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
| 83 | + } |
|
| 84 | + return []; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * @param MigrationService $ms |
|
| 89 | + * @return array associative array of human readable info name as key and the actual information as value |
|
| 90 | + */ |
|
| 91 | + public function getMigrationsInfos(MigrationService $ms) { |
|
| 92 | + |
|
| 93 | + $executedMigrations = $ms->getMigratedVersions(); |
|
| 94 | + $availableMigrations = $ms->getAvailableVersions(); |
|
| 95 | + $executedUnavailableMigrations = array_diff($executedMigrations, array_keys($availableMigrations)); |
|
| 96 | + |
|
| 97 | + $numExecutedUnavailableMigrations = count($executedUnavailableMigrations); |
|
| 98 | + $numNewMigrations = count(array_diff(array_keys($availableMigrations), $executedMigrations)); |
|
| 99 | + |
|
| 100 | + $infos = [ |
|
| 101 | + 'App' => $ms->getApp(), |
|
| 102 | + 'Version Table Name' => $ms->getMigrationsTableName(), |
|
| 103 | + 'Migrations Namespace' => $ms->getMigrationsNamespace(), |
|
| 104 | + 'Migrations Directory' => $ms->getMigrationsDirectory(), |
|
| 105 | + 'Previous Version' => $this->getFormattedVersionAlias($ms, 'prev'), |
|
| 106 | + 'Current Version' => $this->getFormattedVersionAlias($ms, 'current'), |
|
| 107 | + 'Next Version' => $this->getFormattedVersionAlias($ms, 'next'), |
|
| 108 | + 'Latest Version' => $this->getFormattedVersionAlias($ms, 'latest'), |
|
| 109 | + 'Executed Migrations' => count($executedMigrations), |
|
| 110 | + 'Executed Unavailable Migrations' => $numExecutedUnavailableMigrations, |
|
| 111 | + 'Available Migrations' => count($availableMigrations), |
|
| 112 | + 'New Migrations' => $numNewMigrations, |
|
| 113 | + ]; |
|
| 114 | + |
|
| 115 | + return $infos; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * @param MigrationService $migrationService |
|
| 120 | + * @param string $alias |
|
| 121 | + * @return mixed|null|string |
|
| 122 | + */ |
|
| 123 | + private function getFormattedVersionAlias(MigrationService $migrationService, $alias) { |
|
| 124 | + $migration = $migrationService->getMigration($alias); |
|
| 125 | + //No version found |
|
| 126 | + if ($migration === null) { |
|
| 127 | + if ($alias === 'next') { |
|
| 128 | + return 'Already at latest migration step'; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + if ($alias === 'prev') { |
|
| 132 | + return 'Already at first migration step'; |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + return $migration; |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | 139 | |
| 140 | 140 | } |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | class GenerateCommand extends Command implements CompletionAwareInterface { |
| 40 | 40 | |
| 41 | - protected static $_templateSimple = |
|
| 42 | - '<?php |
|
| 41 | + protected static $_templateSimple = |
|
| 42 | + '<?php |
|
| 43 | 43 | namespace {{namespace}}; |
| 44 | 44 | |
| 45 | 45 | use OCP\DB\ISchemaWrapper; |
@@ -82,129 +82,129 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | '; |
| 84 | 84 | |
| 85 | - /** @var IDBConnection */ |
|
| 86 | - protected $connection; |
|
| 87 | - |
|
| 88 | - /** @var IAppManager */ |
|
| 89 | - protected $appManager; |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * @param IDBConnection $connection |
|
| 93 | - * @param IAppManager $appManager |
|
| 94 | - */ |
|
| 95 | - public function __construct(IDBConnection $connection, IAppManager $appManager) { |
|
| 96 | - $this->connection = $connection; |
|
| 97 | - $this->appManager = $appManager; |
|
| 98 | - |
|
| 99 | - parent::__construct(); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - protected function configure() { |
|
| 103 | - $this |
|
| 104 | - ->setName('migrations:generate') |
|
| 105 | - ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on') |
|
| 106 | - ->addArgument('version', InputArgument::REQUIRED, 'Major version of this app, to allow versions on parallel development branches') |
|
| 107 | - ; |
|
| 108 | - |
|
| 109 | - parent::configure(); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - public function execute(InputInterface $input, OutputInterface $output) { |
|
| 113 | - $appName = $input->getArgument('app'); |
|
| 114 | - $version = $input->getArgument('version'); |
|
| 115 | - |
|
| 116 | - if (!preg_match('/^\d{1,16}$/',$version)) { |
|
| 117 | - $output->writeln('<error>The given version is invalid. Only 0-9 are allowed (max. 16 digits)</error>'); |
|
| 118 | - return 1; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
| 122 | - |
|
| 123 | - $date = date('YmdHis'); |
|
| 124 | - $path = $this->generateMigration($ms, 'Version' . $version . 'Date' . $date); |
|
| 125 | - |
|
| 126 | - $output->writeln("New migration class has been generated to <info>$path</info>"); |
|
| 127 | - return 0; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * @param string $optionName |
|
| 132 | - * @param CompletionContext $context |
|
| 133 | - * @return string[] |
|
| 134 | - */ |
|
| 135 | - public function completeOptionValues($optionName, CompletionContext $context) { |
|
| 136 | - return []; |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * @param string $argumentName |
|
| 141 | - * @param CompletionContext $context |
|
| 142 | - * @return string[] |
|
| 143 | - */ |
|
| 144 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
| 145 | - if ($argumentName === 'app') { |
|
| 146 | - $allApps = \OC_App::getAllApps(); |
|
| 147 | - return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - if ($argumentName === 'version') { |
|
| 151 | - $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
|
| 152 | - |
|
| 153 | - $version = explode('.', $this->appManager->getAppVersion($appName)); |
|
| 154 | - return [$version[0] . sprintf('%1$03d', $version[1])]; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - return []; |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * @param MigrationService $ms |
|
| 162 | - * @param string $className |
|
| 163 | - * @param string $schemaBody |
|
| 164 | - * @return string |
|
| 165 | - */ |
|
| 166 | - protected function generateMigration(MigrationService $ms, $className, $schemaBody = '') { |
|
| 167 | - if ($schemaBody === '') { |
|
| 168 | - $schemaBody = "\t\t" . 'return null;'; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - |
|
| 172 | - $placeHolders = [ |
|
| 173 | - '{{namespace}}', |
|
| 174 | - '{{classname}}', |
|
| 175 | - '{{schemabody}}', |
|
| 176 | - ]; |
|
| 177 | - $replacements = [ |
|
| 178 | - $ms->getMigrationsNamespace(), |
|
| 179 | - $className, |
|
| 180 | - $schemaBody, |
|
| 181 | - ]; |
|
| 182 | - $code = str_replace($placeHolders, $replacements, self::$_templateSimple); |
|
| 183 | - $dir = $ms->getMigrationsDirectory(); |
|
| 184 | - |
|
| 185 | - $this->ensureMigrationDirExists($dir); |
|
| 186 | - $path = $dir . '/' . $className . '.php'; |
|
| 187 | - |
|
| 188 | - if (file_put_contents($path, $code) === false) { |
|
| 189 | - throw new RuntimeException('Failed to generate new migration step.'); |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - return $path; |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - protected function ensureMigrationDirExists($directory) { |
|
| 196 | - if (file_exists($directory) && is_dir($directory)) { |
|
| 197 | - return; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - if (file_exists($directory)) { |
|
| 201 | - throw new \RuntimeException("Could not create folder \"$directory\""); |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - $this->ensureMigrationDirExists(dirname($directory)); |
|
| 205 | - |
|
| 206 | - if (!@mkdir($directory) && !is_dir($directory)) { |
|
| 207 | - throw new \RuntimeException("Could not create folder \"$directory\""); |
|
| 208 | - } |
|
| 209 | - } |
|
| 85 | + /** @var IDBConnection */ |
|
| 86 | + protected $connection; |
|
| 87 | + |
|
| 88 | + /** @var IAppManager */ |
|
| 89 | + protected $appManager; |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * @param IDBConnection $connection |
|
| 93 | + * @param IAppManager $appManager |
|
| 94 | + */ |
|
| 95 | + public function __construct(IDBConnection $connection, IAppManager $appManager) { |
|
| 96 | + $this->connection = $connection; |
|
| 97 | + $this->appManager = $appManager; |
|
| 98 | + |
|
| 99 | + parent::__construct(); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + protected function configure() { |
|
| 103 | + $this |
|
| 104 | + ->setName('migrations:generate') |
|
| 105 | + ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on') |
|
| 106 | + ->addArgument('version', InputArgument::REQUIRED, 'Major version of this app, to allow versions on parallel development branches') |
|
| 107 | + ; |
|
| 108 | + |
|
| 109 | + parent::configure(); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + public function execute(InputInterface $input, OutputInterface $output) { |
|
| 113 | + $appName = $input->getArgument('app'); |
|
| 114 | + $version = $input->getArgument('version'); |
|
| 115 | + |
|
| 116 | + if (!preg_match('/^\d{1,16}$/',$version)) { |
|
| 117 | + $output->writeln('<error>The given version is invalid. Only 0-9 are allowed (max. 16 digits)</error>'); |
|
| 118 | + return 1; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
| 122 | + |
|
| 123 | + $date = date('YmdHis'); |
|
| 124 | + $path = $this->generateMigration($ms, 'Version' . $version . 'Date' . $date); |
|
| 125 | + |
|
| 126 | + $output->writeln("New migration class has been generated to <info>$path</info>"); |
|
| 127 | + return 0; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * @param string $optionName |
|
| 132 | + * @param CompletionContext $context |
|
| 133 | + * @return string[] |
|
| 134 | + */ |
|
| 135 | + public function completeOptionValues($optionName, CompletionContext $context) { |
|
| 136 | + return []; |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * @param string $argumentName |
|
| 141 | + * @param CompletionContext $context |
|
| 142 | + * @return string[] |
|
| 143 | + */ |
|
| 144 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
| 145 | + if ($argumentName === 'app') { |
|
| 146 | + $allApps = \OC_App::getAllApps(); |
|
| 147 | + return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + if ($argumentName === 'version') { |
|
| 151 | + $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
|
| 152 | + |
|
| 153 | + $version = explode('.', $this->appManager->getAppVersion($appName)); |
|
| 154 | + return [$version[0] . sprintf('%1$03d', $version[1])]; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + return []; |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * @param MigrationService $ms |
|
| 162 | + * @param string $className |
|
| 163 | + * @param string $schemaBody |
|
| 164 | + * @return string |
|
| 165 | + */ |
|
| 166 | + protected function generateMigration(MigrationService $ms, $className, $schemaBody = '') { |
|
| 167 | + if ($schemaBody === '') { |
|
| 168 | + $schemaBody = "\t\t" . 'return null;'; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + |
|
| 172 | + $placeHolders = [ |
|
| 173 | + '{{namespace}}', |
|
| 174 | + '{{classname}}', |
|
| 175 | + '{{schemabody}}', |
|
| 176 | + ]; |
|
| 177 | + $replacements = [ |
|
| 178 | + $ms->getMigrationsNamespace(), |
|
| 179 | + $className, |
|
| 180 | + $schemaBody, |
|
| 181 | + ]; |
|
| 182 | + $code = str_replace($placeHolders, $replacements, self::$_templateSimple); |
|
| 183 | + $dir = $ms->getMigrationsDirectory(); |
|
| 184 | + |
|
| 185 | + $this->ensureMigrationDirExists($dir); |
|
| 186 | + $path = $dir . '/' . $className . '.php'; |
|
| 187 | + |
|
| 188 | + if (file_put_contents($path, $code) === false) { |
|
| 189 | + throw new RuntimeException('Failed to generate new migration step.'); |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + return $path; |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + protected function ensureMigrationDirExists($directory) { |
|
| 196 | + if (file_exists($directory) && is_dir($directory)) { |
|
| 197 | + return; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + if (file_exists($directory)) { |
|
| 201 | + throw new \RuntimeException("Could not create folder \"$directory\""); |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + $this->ensureMigrationDirExists(dirname($directory)); |
|
| 205 | + |
|
| 206 | + if (!@mkdir($directory) && !is_dir($directory)) { |
|
| 207 | + throw new \RuntimeException("Could not create folder \"$directory\""); |
|
| 208 | + } |
|
| 209 | + } |
|
| 210 | 210 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | $appName = $input->getArgument('app'); |
| 114 | 114 | $version = $input->getArgument('version'); |
| 115 | 115 | |
| 116 | - if (!preg_match('/^\d{1,16}$/',$version)) { |
|
| 116 | + if (!preg_match('/^\d{1,16}$/', $version)) { |
|
| 117 | 117 | $output->writeln('<error>The given version is invalid. Only 0-9 are allowed (max. 16 digits)</error>'); |
| 118 | 118 | return 1; |
| 119 | 119 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
| 122 | 122 | |
| 123 | 123 | $date = date('YmdHis'); |
| 124 | - $path = $this->generateMigration($ms, 'Version' . $version . 'Date' . $date); |
|
| 124 | + $path = $this->generateMigration($ms, 'Version'.$version.'Date'.$date); |
|
| 125 | 125 | |
| 126 | 126 | $output->writeln("New migration class has been generated to <info>$path</info>"); |
| 127 | 127 | return 0; |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
| 152 | 152 | |
| 153 | 153 | $version = explode('.', $this->appManager->getAppVersion($appName)); |
| 154 | - return [$version[0] . sprintf('%1$03d', $version[1])]; |
|
| 154 | + return [$version[0].sprintf('%1$03d', $version[1])]; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | return []; |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | */ |
| 166 | 166 | protected function generateMigration(MigrationService $ms, $className, $schemaBody = '') { |
| 167 | 167 | if ($schemaBody === '') { |
| 168 | - $schemaBody = "\t\t" . 'return null;'; |
|
| 168 | + $schemaBody = "\t\t".'return null;'; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | $dir = $ms->getMigrationsDirectory(); |
| 184 | 184 | |
| 185 | 185 | $this->ensureMigrationDirExists($dir); |
| 186 | - $path = $dir . '/' . $className . '.php'; |
|
| 186 | + $path = $dir.'/'.$className.'.php'; |
|
| 187 | 187 | |
| 188 | 188 | if (file_put_contents($path, $code) === false) { |
| 189 | 189 | throw new RuntimeException('Failed to generate new migration step.'); |