Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable option '--no-interaction' for db:convert-type #18576

Merged
merged 2 commits into from
Jan 7, 2020
Merged

enable option '--no-interaction' for db:convert-type #18576

merged 2 commits into from
Jan 7, 2020

Conversation

BernieO
Copy link
Contributor

@BernieO BernieO commented Dec 27, 2019

Signed-off-by: Bernhard Ostertag bernieo.code@gmx.de

When converting database type the option --no-interaction is currently ignored, which makes it impossible for some users to change the database type via occ (for example see: https://help.nextcloud.com/t/failed-to-connect-to-database-when-converting-sqlite-to-mysql/66782/7)

This pull request adds a check for the option --no-interaction for the command occ db:convert-type

Signed-off-by: Bernhard Ostertag <bernieo.code@gmx.de>
@kesselb
Copy link
Contributor

kesselb commented Dec 27, 2019

Thanks 👍

Console has some logic in place for such cases: https://github.com/nextcloud/3rdparty/blob/cc36ef4e9f63e0dd6009851d6f8a84a31911b57b/symfony/console/Helper/QuestionHelper.php#L49-L73

Index: core/Command/Db/ConvertType.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/Command/Db/ConvertType.php	(revision b7f93cc56bb1f7d9383165ebf29111fbd2bd6ab1)
+++ core/Command/Db/ConvertType.php	(date 1577458133111)
@@ -212,10 +212,11 @@
 				$output->writeln('<comment>can be included by specifying the --all-apps option.</comment>');
 			}
 
+			$continueConversion = !$input->isInteractive(); // assume yes for --no-interaction and no otherwise.
+			$question = new ConfirmationQuestion('Continue with the conversion (y/n)? [n] ', $continueConversion);
+
 			/** @var QuestionHelper $helper */
 			$helper = $this->getHelper('question');
-			$question = new ConfirmationQuestion('Continue with the conversion (y/n)? [n] ', false);
-
 			if (!$helper->ask($input, $output, $question)) {
 				return;
 			}

I would suggest to introduce a new variable with the default answer. Set it to true for no-interactive and false otherwise.

@BernieO
Copy link
Contributor Author

BernieO commented Dec 28, 2019

That looks better. Should I create another pull request with the changes you proposed?

Another thing: should that as option be added to the documentation here (I could do that as well):
https://github.com/nextcloud/documentation/blob/master/admin_manual/configuration_database/db_conversion.rst
?

@kesselb
Copy link
Contributor

kesselb commented Dec 28, 2019

That looks better. Should I create another pull request with the changes you proposed?

Update this pr if possible. We can also keep the current approach. The result is the same.

should that as option be added to the documentation here

Yes. Thanks in advance 👍

…nteraction for command occ db:convert-type

Variable is set to true for --no-interaction and false otherwise

Signed-off-by: Bernhard Ostertag <bernieo.code@gmx.de>
@BernieO
Copy link
Contributor Author

BernieO commented Dec 29, 2019

I changed the documentation accordingly: nextcloud/documentation#1755

I suggest to backport this to stable 17 and stable 16.

@kesselb kesselb added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Jan 7, 2020
@kesselb kesselb added this to the Nextcloud 18 milestone Jan 7, 2020
@kesselb
Copy link
Contributor

kesselb commented Jan 7, 2020

If someone of you could press merge ;)

@ChristophWurst ChristophWurst merged commit 4defd04 into nextcloud:master Jan 7, 2020
@ChristophWurst
Copy link
Member

mörged!

@rullzer rullzer mentioned this pull request Jan 7, 2020
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants