diff options
author | Christoph Wurst <ChristophWurst@users.noreply.github.com> | 2022-02-28 09:59:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-28 09:59:40 +0100 |
commit | c1000fe3449f239826b183a57af93905e61cd0f8 (patch) | |
tree | 541fa2f2f6d3d9276b15c985a76703c2b8ebe230 /lib | |
parent | 3bae591e9c0182e3dd0e2ea421265980c6467b19 (diff) | |
parent | 405c5eb8138a476dafe8b8ea4105788f1ac8ebca (diff) | |
download | nextcloud-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.php | 12 |
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() { |