summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChristoph Wurst <ChristophWurst@users.noreply.github.com>2022-02-28 09:59:40 +0100
committerGitHub <noreply@github.com>2022-02-28 09:59:40 +0100
commitc1000fe3449f239826b183a57af93905e61cd0f8 (patch)
tree541fa2f2f6d3d9276b15c985a76703c2b8ebe230 /lib
parent3bae591e9c0182e3dd0e2ea421265980c6467b19 (diff)
parent405c5eb8138a476dafe8b8ea4105788f1ac8ebca (diff)
downloadnextcloud-server-c1000fe3449f239826b183a57af93905e61cd0f8.tar.gz
nextcloud-server-c1000fe3449f239826b183a57af93905e61cd0f8.zip
Merge pull request #31304 from nextcloud/feature/dry_run_for_add_indices
Add --dry-run option for add-missing-* cmd
Diffstat (limited to 'lib')
-rw-r--r--lib/private/DB/Connection.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php
index b8d1a747fa2..2203893d427 100644
--- a/lib/private/DB/Connection.php
+++ b/lib/private/DB/Connection.php
@@ -538,12 +538,20 @@ class Connection extends \Doctrine\DBAL\Connection {
* Migrate the database to the given schema
*
* @param Schema $toSchema
+ * @param bool $dryRun If true, will return the sql queries instead of running them.
*
* @throws Exception
+ *
+ * @return string|null Returns a string only if $dryRun is true.
*/
- public function migrateToSchema(Schema $toSchema) {
+ public function migrateToSchema(Schema $toSchema, bool $dryRun = false) {
$migrator = $this->getMigrator();
- $migrator->migrate($toSchema);
+
+ if ($dryRun) {
+ return $migrator->generateChangeScript($toSchema);
+ } else {
+ $migrator->migrate($toSchema);
+ }
}
private function getMigrator() {