Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2022-04-26 12:23:33 +0300
committerGitHub <noreply@github.com>2022-04-26 12:23:33 +0300
commitc798e948769515298f523548b55707dd9ae4c725 (patch)
tree50cb5e57f19feb61961068728b2decb73bd92c2e /core
parent8a3f8b07a8b8b4f7dd618ddc42d2d4698d30a31a (diff)
parent2ffcc08332632cddc64236917c35659939ec4f97 (diff)
Merge pull request #32137 from nextcloud/techdebt/noid/give-hints-on-correct-migration-names
Give hints on correct migration versioning
Diffstat (limited to 'core')
-rw-r--r--core/Command/Db/Migrations/GenerateCommand.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/core/Command/Db/Migrations/GenerateCommand.php b/core/Command/Db/Migrations/GenerateCommand.php
index 1710816cbba..9790a96a0fd 100644
--- a/core/Command/Db/Migrations/GenerateCommand.php
+++ b/core/Command/Db/Migrations/GenerateCommand.php
@@ -28,6 +28,7 @@ use OC\DB\Connection;
use OC\DB\MigrationService;
use OC\Migration\ConsoleOutput;
use OCP\App\IAppManager;
+use OCP\Util;
use Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionAwareInterface;
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
use Symfony\Component\Console\Command\Command;
@@ -35,6 +36,7 @@ use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Question\ConfirmationQuestion;
class GenerateCommand extends Command implements CompletionAwareInterface {
protected static $_templateSimple =
@@ -140,6 +142,36 @@ class {{classname}} extends SimpleMigrationStep {
return 1;
}
+ if ($appName === 'core') {
+ $fullVersion = implode('.', Util::getVersion());
+ } else {
+ try {
+ $fullVersion = $this->appManager->getAppVersion($appName, false);
+ } catch (\Throwable $e) {
+ $fullVersion = '';
+ }
+ }
+
+ if ($fullVersion) {
+ [$major, $minor] = explode('.', $fullVersion);
+ $shouldVersion = (int)$major * 1000 + (int)$minor;
+ if ($version !== $shouldVersion) {
+ $output->writeln('<comment>Unexpected migration version for current version: ' . $fullVersion . '</comment>');
+ $output->writeln('<comment> - Pattern: XYYY </comment>');
+ $output->writeln('<comment> - Expected: ' . $shouldVersion . '</comment>');
+ $output->writeln('<comment> - Actual: ' . $version . '</comment>');
+
+ if ($input->isInteractive()) {
+ $helper = $this->getHelper('question');
+ $question = new ConfirmationQuestion('Continue with your given version? (y/n) [n] ', false);
+
+ if (!$helper->ask($input, $output, $question)) {
+ return 1;
+ }
+ }
+ }
+ }
+
$ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output));
$date = date('YmdHis');