diff options
author | Louis Chemineau <louis@chmn.me> | 2022-02-21 18:32:17 +0100 |
---|---|---|
committer | Louis Chemineau <louis@chmn.me> | 2022-02-24 16:42:08 +0100 |
commit | 405c5eb8138a476dafe8b8ea4105788f1ac8ebca (patch) | |
tree | baac4b3964932e8d26d0bdd4feda8a0bfd078420 /lib | |
parent | 6ab9a13ad9341bcdc1f6fc0ff866e430d5ebf956 (diff) | |
download | nextcloud-server-405c5eb8138a476dafe8b8ea4105788f1ac8ebca.tar.gz nextcloud-server-405c5eb8138a476dafe8b8ea4105788f1ac8ebca.zip |
Add --dry-run option for db:add-missing-* cmd
Signed-off-by: Louis Chemineau <louis@chmn.me>
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() { |