From c02e88023653be82345f3e22e8ddb7c74a0e1233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Fri, 13 Mar 2015 00:12:11 +0100 Subject: [PATCH 1/7] Adding doctrine/migrations Signed-off-by: Lukas Reschke --- core/command/db/migrations/executecommand.php | 51 +++++++++++++++++++ .../command/db/migrations/generatecommand.php | 51 +++++++++++++++++++ core/command/db/migrations/migratecommand.php | 51 +++++++++++++++++++ core/command/db/migrations/migrationtrait.php | 42 +++++++++++++++ core/command/db/migrations/statuscommand.php | 51 +++++++++++++++++++ core/register_command.php | 4 ++ 6 files changed, 250 insertions(+) create mode 100644 core/command/db/migrations/executecommand.php create mode 100644 core/command/db/migrations/generatecommand.php create mode 100644 core/command/db/migrations/migratecommand.php create mode 100644 core/command/db/migrations/migrationtrait.php create mode 100644 core/command/db/migrations/statuscommand.php diff --git a/core/command/db/migrations/executecommand.php b/core/command/db/migrations/executecommand.php new file mode 100644 index 0000000000000..a9877fa5c2947 --- /dev/null +++ b/core/command/db/migrations/executecommand.php @@ -0,0 +1,51 @@ +config = $config; + $this->ocConnection = $connection; + + parent::__construct(); + } + + protected function configure() { + $this->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on'); + + parent::configure(); + } + + public function execute(InputInterface $input, OutputInterface $output) { + $appName = $input->getArgument('app'); + $mc = $this->buildConfiguration($appName, $this->ocConnection); + $this->setMigrationConfiguration($mc); + + parent::execute($input, $output); + } + +} diff --git a/core/command/db/migrations/generatecommand.php b/core/command/db/migrations/generatecommand.php new file mode 100644 index 0000000000000..72a720d3a0219 --- /dev/null +++ b/core/command/db/migrations/generatecommand.php @@ -0,0 +1,51 @@ +config = $config; + $this->ocConnection = $connection; + + parent::__construct(); + } + + protected function configure() { + $this->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on'); + + parent::configure(); + } + + public function execute(InputInterface $input, OutputInterface $output) { + $appName = $input->getArgument('app'); + $mc = $this->buildConfiguration($appName, $this->ocConnection); + $this->setMigrationConfiguration($mc); + + parent::execute($input, $output); + } + +} diff --git a/core/command/db/migrations/migratecommand.php b/core/command/db/migrations/migratecommand.php new file mode 100644 index 0000000000000..45678a49de142 --- /dev/null +++ b/core/command/db/migrations/migratecommand.php @@ -0,0 +1,51 @@ +config = $config; + $this->ocConnection = $connection; + + parent::__construct(); + } + + protected function configure() { + $this->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on'); + + parent::configure(); + } + + public function execute(InputInterface $input, OutputInterface $output) { + $appName = $input->getArgument('app'); + $mc = $this->buildConfiguration($appName, $this->ocConnection); + $this->setMigrationConfiguration($mc); + + parent::execute($input, $output); + } + +} diff --git a/core/command/db/migrations/migrationtrait.php b/core/command/db/migrations/migrationtrait.php new file mode 100644 index 0000000000000..ce1eed795326c --- /dev/null +++ b/core/command/db/migrations/migrationtrait.php @@ -0,0 +1,42 @@ +setMigrationsDirectory(\OC::$SERVERROOT."/core/migrations"); + $mc->setMigrationsNamespace("OC\\Migrations"); + $mc->setMigrationsTableName("core_migration_versions"); + return $mc; + } + $appPath = \OC_App::getAppPath($appName); + if (!$appPath) { + throw new InvalidArgumentException('Path to app is not defined.'); + } + + $mc = new Configuration($connection); + $mc->setMigrationsDirectory(\OC::$SERVERROOT."/$appPath/appinfo/migrations"); + $mc->setMigrationsNamespace("OCA\\$appName\\Migrations"); + $mc->setMigrationsTableName("{$appName}_migration_versions"); + return $mc; + } + +} diff --git a/core/command/db/migrations/statuscommand.php b/core/command/db/migrations/statuscommand.php new file mode 100644 index 0000000000000..c45b6ef7ff381 --- /dev/null +++ b/core/command/db/migrations/statuscommand.php @@ -0,0 +1,51 @@ +config = $config; + $this->ocConnection = $connection; + + parent::__construct(); + } + + protected function configure() { + parent::configure(); + + $this->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on'); + } + + public function execute(InputInterface $input, OutputInterface $output) { + $appName = $input->getArgument('app'); + $mc = $this->buildConfiguration($appName, $this->ocConnection); + $this->setMigrationConfiguration($mc); + + parent::execute($input, $output); + } + +} diff --git a/core/register_command.php b/core/register_command.php index 6f31adafe926f..671274f7e503b 100644 --- a/core/register_command.php +++ b/core/register_command.php @@ -84,6 +84,10 @@ $application->add(new OC\Core\Command\Db\GenerateChangeScript()); $application->add(new OC\Core\Command\Db\ConvertType(\OC::$server->getConfig(), new \OC\DB\ConnectionFactory(\OC::$server->getConfig()))); + $application->add(new OC\Core\Command\Db\Migrations\StatusCommand(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection())); + $application->add(new OC\Core\Command\Db\Migrations\MigrateCommand(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection())); + $application->add(new OC\Core\Command\Db\Migrations\GenerateCommand(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection())); + $application->add(new OC\Core\Command\Db\Migrations\ExecuteCommand(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection())); $application->add(new OC\Core\Command\Encryption\Disable(\OC::$server->getConfig())); $application->add(new OC\Core\Command\Encryption\Enable(\OC::$server->getConfig(), \OC::$server->getEncryptionManager())); From f20a15d4b4fbc027cb7ddf7b55ad6d353d5cf197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Thu, 30 Jun 2016 23:30:08 +0200 Subject: [PATCH 2/7] Integrate doctrine migrations with core and app upgrade Signed-off-by: Lukas Reschke --- .../Db/Migrations/ExecuteCommand.php} | 28 +++++-- .../Db/Migrations/GenerateCommand.php} | 28 +++++-- .../Db/Migrations/MigrateCommand.php} | 28 +++++-- .../Db/Migrations/StatusCommand.php} | 28 +++++-- core/command/db/migrations/migrationtrait.php | 42 ----------- lib/private/DB/MDB2SchemaReader.php | 6 +- lib/private/DB/MigrationConfiguration.php | 45 ++++++++++++ lib/private/DB/MigrationService.php | 73 +++++++++++++++++++ lib/private/DB/OracleConnection.php | 29 +++++--- lib/private/Installer.php | 36 ++++++--- lib/private/Setup.php | 2 + lib/private/Setup/AbstractDatabase.php | 13 ++++ lib/private/Updater.php | 9 ++- lib/private/legacy/app.php | 10 ++- 14 files changed, 279 insertions(+), 98 deletions(-) rename core/{command/db/migrations/executecommand.php => Command/Db/Migrations/ExecuteCommand.php} (54%) rename core/{command/db/migrations/generatecommand.php => Command/Db/Migrations/GenerateCommand.php} (54%) rename core/{command/db/migrations/migratecommand.php => Command/Db/Migrations/MigrateCommand.php} (54%) rename core/{command/db/migrations/statuscommand.php => Command/Db/Migrations/StatusCommand.php} (54%) delete mode 100644 core/command/db/migrations/migrationtrait.php create mode 100644 lib/private/DB/MigrationConfiguration.php create mode 100644 lib/private/DB/MigrationService.php diff --git a/core/command/db/migrations/executecommand.php b/core/Command/Db/Migrations/ExecuteCommand.php similarity index 54% rename from core/command/db/migrations/executecommand.php rename to core/Command/Db/Migrations/ExecuteCommand.php index a9877fa5c2947..8f864e930de56 100644 --- a/core/command/db/migrations/executecommand.php +++ b/core/Command/Db/Migrations/ExecuteCommand.php @@ -1,11 +1,22 @@ + * + * @copyright Copyright (c) 2016, ownCloud GmbH. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see * - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. */ namespace OC\Core\Command\Db\Migrations; @@ -13,13 +24,13 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand as DBALExecuteCommand; +use OC\DB\MigrationService; use OCP\IConfig; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class ExecuteCommand extends DBALExecuteCommand { - use MigrationTrait; /** @var Connection */ private $ocConnection; @@ -42,7 +53,8 @@ protected function configure() { public function execute(InputInterface $input, OutputInterface $output) { $appName = $input->getArgument('app'); - $mc = $this->buildConfiguration($appName, $this->ocConnection); + $ms = new MigrationService(); + $mc = $ms->buildConfiguration($appName, $this->ocConnection); $this->setMigrationConfiguration($mc); parent::execute($input, $output); diff --git a/core/command/db/migrations/generatecommand.php b/core/Command/Db/Migrations/GenerateCommand.php similarity index 54% rename from core/command/db/migrations/generatecommand.php rename to core/Command/Db/Migrations/GenerateCommand.php index 72a720d3a0219..3f738f81dddd9 100644 --- a/core/command/db/migrations/generatecommand.php +++ b/core/Command/Db/Migrations/GenerateCommand.php @@ -1,11 +1,22 @@ + * + * @copyright Copyright (c) 2016, ownCloud GmbH. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see * - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. */ namespace OC\Core\Command\Db\Migrations; @@ -13,13 +24,13 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand as DBALGenerateCommand; +use OC\DB\MigrationService; use OCP\IConfig; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class GenerateCommand extends DBALGenerateCommand { - use MigrationTrait; /** @var Connection */ private $ocConnection; @@ -42,7 +53,8 @@ protected function configure() { public function execute(InputInterface $input, OutputInterface $output) { $appName = $input->getArgument('app'); - $mc = $this->buildConfiguration($appName, $this->ocConnection); + $ms = new MigrationService(); + $mc = $ms->buildConfiguration($appName, $this->ocConnection); $this->setMigrationConfiguration($mc); parent::execute($input, $output); diff --git a/core/command/db/migrations/migratecommand.php b/core/Command/Db/Migrations/MigrateCommand.php similarity index 54% rename from core/command/db/migrations/migratecommand.php rename to core/Command/Db/Migrations/MigrateCommand.php index 45678a49de142..5d6ff09c9b980 100644 --- a/core/command/db/migrations/migratecommand.php +++ b/core/Command/Db/Migrations/MigrateCommand.php @@ -1,11 +1,22 @@ + * + * @copyright Copyright (c) 2016, ownCloud GmbH. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see * - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. */ namespace OC\Core\Command\Db\Migrations; @@ -13,13 +24,13 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand as DBALMigrateCommand; +use OC\DB\MigrationService; use OCP\IConfig; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class MigrateCommand extends DBALMigrateCommand { - use MigrationTrait; /** @var Connection */ private $ocConnection; @@ -42,7 +53,8 @@ protected function configure() { public function execute(InputInterface $input, OutputInterface $output) { $appName = $input->getArgument('app'); - $mc = $this->buildConfiguration($appName, $this->ocConnection); + $ms = new MigrationService(); + $mc = $ms->buildConfiguration($appName, $this->ocConnection); $this->setMigrationConfiguration($mc); parent::execute($input, $output); diff --git a/core/command/db/migrations/statuscommand.php b/core/Command/Db/Migrations/StatusCommand.php similarity index 54% rename from core/command/db/migrations/statuscommand.php rename to core/Command/Db/Migrations/StatusCommand.php index c45b6ef7ff381..6fd4420d6f20f 100644 --- a/core/command/db/migrations/statuscommand.php +++ b/core/Command/Db/Migrations/StatusCommand.php @@ -1,11 +1,22 @@ + * + * @copyright Copyright (c) 2016, ownCloud GmbH. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see * - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. */ namespace OC\Core\Command\Db\Migrations; @@ -13,13 +24,13 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand as DBALStatusCommand; +use OC\DB\MigrationService; use OCP\IConfig; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class StatusCommand extends DBALStatusCommand { - use MigrationTrait; /** @var Connection */ private $ocConnection; @@ -42,7 +53,8 @@ protected function configure() { public function execute(InputInterface $input, OutputInterface $output) { $appName = $input->getArgument('app'); - $mc = $this->buildConfiguration($appName, $this->ocConnection); + $ms = new MigrationService(); + $mc = $ms->buildConfiguration($appName, $this->ocConnection); $this->setMigrationConfiguration($mc); parent::execute($input, $output); diff --git a/core/command/db/migrations/migrationtrait.php b/core/command/db/migrations/migrationtrait.php deleted file mode 100644 index ce1eed795326c..0000000000000 --- a/core/command/db/migrations/migrationtrait.php +++ /dev/null @@ -1,42 +0,0 @@ -setMigrationsDirectory(\OC::$SERVERROOT."/core/migrations"); - $mc->setMigrationsNamespace("OC\\Migrations"); - $mc->setMigrationsTableName("core_migration_versions"); - return $mc; - } - $appPath = \OC_App::getAppPath($appName); - if (!$appPath) { - throw new InvalidArgumentException('Path to app is not defined.'); - } - - $mc = new Configuration($connection); - $mc->setMigrationsDirectory(\OC::$SERVERROOT."/$appPath/appinfo/migrations"); - $mc->setMigrationsNamespace("OCA\\$appName\\Migrations"); - $mc->setMigrationsTableName("{$appName}_migration_versions"); - return $mc; - } - -} diff --git a/lib/private/DB/MDB2SchemaReader.php b/lib/private/DB/MDB2SchemaReader.php index c198bb31e0011..205fe79f2b7d9 100644 --- a/lib/private/DB/MDB2SchemaReader.php +++ b/lib/private/DB/MDB2SchemaReader.php @@ -80,8 +80,10 @@ public function __construct(IConfig $config, AbstractPlatform $platform) { * @return \Doctrine\DBAL\Schema\Schema * @throws \DomainException */ - public function loadSchemaFromFile($file) { - $schema = new \Doctrine\DBAL\Schema\Schema(); + public function loadSchemaFromFile($file, $schema = null) { + if (is_null($schema)) { + $schema = new \Doctrine\DBAL\Schema\Schema(); + } $loadEntities = libxml_disable_entity_loader(false); $xml = simplexml_load_file($file); libxml_disable_entity_loader($loadEntities); diff --git a/lib/private/DB/MigrationConfiguration.php b/lib/private/DB/MigrationConfiguration.php new file mode 100644 index 0000000000000..ab65ce1d6051f --- /dev/null +++ b/lib/private/DB/MigrationConfiguration.php @@ -0,0 +1,45 @@ + + * + * @copyright Copyright (c) 2016, ownCloud GmbH + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ +namespace OC\DB; + +use Doctrine\DBAL\Migrations\Finder\MigrationFinderInterface; +use Doctrine\DBAL\Migrations\OutputWriter; + +class MigrationConfiguration extends \Doctrine\DBAL\Migrations\Configuration\Configuration { + + function __construct(Connection $connection, OutputWriter $outputWriter = null, MigrationFinderInterface $finder = null) { + parent::__construct($connection, $outputWriter, $finder); + + $this->setMigrationsTableName($this->getMigrationsTableName()); + $this->setMigrationsColumnName($this->getMigrationsColumnName()); + } + + public function setMigrationsColumnName($columnName) { + $columnName = $this->getConnection()->getDatabasePlatform()->quoteIdentifier($columnName); + parent::setMigrationsColumnName($columnName); + } + + public function setMigrationsTableName($tableName) { + $tableName = $this->getConnection()->getDatabasePlatform()->quoteIdentifier($tableName); + parent::setMigrationsTableName($tableName); + } + +} diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php new file mode 100644 index 0000000000000..b9ea1395fadc3 --- /dev/null +++ b/lib/private/DB/MigrationService.php @@ -0,0 +1,73 @@ + + * + * @copyright Copyright (c) 2016, ownCloud GmbH. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ + +namespace OC\DB; + +use Doctrine\DBAL\Migrations\Configuration\Configuration; +use Doctrine\DBAL\Migrations\Migration; +use Doctrine\DBAL\Migrations\OutputWriter; +use OCP\IDBConnection; + +class MigrationService { + + /** + * @param string $appName + * @param IDBConnection $connection + * @return Configuration + */ + public function buildConfiguration($appName, $connection) { + if ($appName === 'core') { + $migrationsPath = \OC::$SERVERROOT . '/core/Migrations'; + $migrationsNamespace = 'OC\\Migrations'; + } else { + $appPath = \OC_App::getAppPath($appName); + if (!$appPath) { + throw new \InvalidArgumentException('Path to app is not defined.'); + } + $migrationsPath = "$appPath/appinfo/Migrations"; + $migrationsNamespace = "OCA\\$appName\\Migrations"; + } + + if (!is_dir($migrationsPath)) { + mkdir($migrationsPath); + } + $prefix = $connection->getPrefix(); + $mc = new MigrationConfiguration($connection); + $mc->setMigrationsDirectory($migrationsPath); + $mc->setMigrationsNamespace($migrationsNamespace); + $mc->setMigrationsTableName("{$prefix}{$appName}_migration_versions"); + return $mc; + } + + /** + * @param Configuration $migrationConfiguration + * @param bool $noMigrationException + */ + public function migrate($migrationConfiguration, $noMigrationException = false) { + $migrationConfiguration->setOutputWriter(new OutputWriter(function ($message){ + \OCP\Util::writeLog('migrations', $message, \OCP\Util::INFO); + })); + + $migration = new Migration($migrationConfiguration); + $migration->setNoMigrationException($noMigrationException); + $migration->migrate(); + } +} diff --git a/lib/private/DB/OracleConnection.php b/lib/private/DB/OracleConnection.php index 08d713651722a..106f219d1a9ba 100644 --- a/lib/private/DB/OracleConnection.php +++ b/lib/private/DB/OracleConnection.php @@ -30,9 +30,14 @@ class OracleConnection extends Connection { * Quote the keys of the array */ private function quoteKeys(array $data) { - $return = array(); + $return = []; + $c = $this->getDatabasePlatform()->getIdentifierQuoteCharacter(); foreach($data as $key => $value) { - $return[$this->quoteIdentifier($key)] = $value; + if ($key[0] !== $c) { + $return[$this->quoteIdentifier($key)] = $value; + } else { + $return[$key] = $value; + } } return $return; } @@ -40,8 +45,10 @@ private function quoteKeys(array $data) { /** * {@inheritDoc} */ - public function insert($tableName, array $data, array $types = array()) { - $tableName = $this->quoteIdentifier($tableName); + public function insert($tableName, array $data, array $types = []) { + if ($tableName[0] !== $this->getDatabasePlatform()->getIdentifierQuoteCharacter()) { + $tableName = $this->quoteIdentifier($tableName); + } $data = $this->quoteKeys($data); return parent::insert($tableName, $data, $types); } @@ -49,8 +56,10 @@ public function insert($tableName, array $data, array $types = array()) { /** * {@inheritDoc} */ - public function update($tableName, array $data, array $identifier, array $types = array()) { - $tableName = $this->quoteIdentifier($tableName); + public function update($tableName, array $data, array $identifier, array $types = []) { + if ($tableName[0] !== $this->getDatabasePlatform()->getIdentifierQuoteCharacter()) { + $tableName = $this->quoteIdentifier($tableName); + } $data = $this->quoteKeys($data); $identifier = $this->quoteKeys($identifier); return parent::update($tableName, $data, $identifier, $types); @@ -59,10 +68,12 @@ public function update($tableName, array $data, array $identifier, array $types /** * {@inheritDoc} */ - public function delete($tableExpression, array $identifier, array $types = array()) { - $tableName = $this->quoteIdentifier($tableExpression); + public function delete($tableExpression, array $identifier, array $types = []) { + if ($tableExpression[0] !== $this->getDatabasePlatform()->getIdentifierQuoteCharacter()) { + $tableExpression = $this->quoteIdentifier($tableExpression); + } $identifier = $this->quoteKeys($identifier); - return parent::delete($tableName, $identifier); + return parent::delete($tableExpression, $identifier); } /** diff --git a/lib/private/Installer.php b/lib/private/Installer.php index 38d0ce1368473..547052a496bf9 100644 --- a/lib/private/Installer.php +++ b/lib/private/Installer.php @@ -102,11 +102,17 @@ public function installApp($appId) { $info = OC_App::getAppInfo($basedir.'/appinfo/info.xml', true); //install the database - if(is_file($basedir.'/appinfo/database.xml')) { - if (\OC::$server->getAppConfig()->getValue($info['id'], 'installed_version') === null) { - OC_DB::createDbFromStructure($basedir.'/appinfo/database.xml'); - } else { - OC_DB::updateDbFromStructure($basedir.'/appinfo/database.xml'); + if (isset($appData['use-migrations']) && $appData['use-migrations'] === 'true') { + $ms = new \OC\DB\MigrationService(); + $mc = $ms->buildConfiguration($appId, \OC::$server->getDatabaseConnection()); + $ms->migrate($mc); + } else { + if(is_file($basedir.'/appinfo/database.xml')) { + if (\OC::$server->getAppConfig()->getValue($info['id'], 'installed_version') === null) { + OC_DB::createDbFromStructure($basedir . '/appinfo/database.xml'); + } else { + OC_DB::updateDbFromStructure($basedir . '/appinfo/database.xml'); + } } } @@ -472,8 +478,15 @@ public static function installShippedApps($softErrors = false) { * @return integer */ public static function installShippedApp($app) { + + $info = OC_App::getAppInfo($app); + if (is_null($info)) { + return false; + } + //install the database $appPath = OC_App::getAppPath($app); +<<<<<<< HEAD if(is_file("$appPath/appinfo/database.xml")) { try { OC_DB::createDbFromStructure("$appPath/appinfo/database.xml"); @@ -483,6 +496,15 @@ public static function installShippedApp($app) { 'Please ask for help via one of our support channels.', 0, $e ); +======= + if (isset($info['use-migrations']) && $info['use-migrations'] === 'true') { + $ms = new \OC\DB\MigrationService(); + $mc = $ms->buildConfiguration($app, \OC::$server->getDatabaseConnection()); + $ms->migrate($mc); + } else { + if(is_file($appPath.'/appinfo/database.xml')) { + OC_DB::createDbFromStructure($appPath . '/appinfo/database.xml'); +>>>>>>> 87aa059... Integrate doctrine migrations with core and app upgrade } } @@ -490,10 +512,6 @@ public static function installShippedApp($app) { \OC_App::registerAutoloading($app, $appPath); self::includeAppScript("$appPath/appinfo/install.php"); - $info = OC_App::getAppInfo($app); - if (is_null($info)) { - return false; - } \OC_App::setupBackgroundJobs($info['background-jobs']); OC_App::executeRepairSteps($app, $info['repair-steps']['install']); diff --git a/lib/private/Setup.php b/lib/private/Setup.php index 81a5343fe2103..944f3a01a9eeb 100644 --- a/lib/private/Setup.php +++ b/lib/private/Setup.php @@ -330,6 +330,8 @@ public function install($options) { try { $dbSetup->initialize($options); $dbSetup->setupDatabase($username); + // apply necessary migrations + $dbSetup->runMigrations(); } catch (\OC\DatabaseSetupException $e) { $error[] = array( 'error' => $e->getMessage(), diff --git a/lib/private/Setup/AbstractDatabase.php b/lib/private/Setup/AbstractDatabase.php index dbf46888ffe3c..fbc39c4c341a0 100644 --- a/lib/private/Setup/AbstractDatabase.php +++ b/lib/private/Setup/AbstractDatabase.php @@ -26,8 +26,12 @@ */ namespace OC\Setup; +<<<<<<< HEAD use OC\AllConfig; use OC\DB\ConnectionFactory; +======= +use OC\DB\MigrationService; +>>>>>>> 87aa059... Integrate doctrine migrations with core and app upgrade use OCP\IConfig; use OCP\IL10N; use OCP\ILogger; @@ -144,4 +148,13 @@ protected function connect(array $configOverwrite = []) { * @param string $userName */ abstract public function setupDatabase($userName); + + public function runMigrations() { + if (!is_dir(\OC::$SERVERROOT."/core/Migrations")) { + return; + } + $ms = new MigrationService(); + $mc = $ms->buildConfiguration('core', \OC::$server->getDatabaseConnection()); + $ms->migrate($mc, true); + } } diff --git a/lib/private/Updater.php b/lib/private/Updater.php index a66d49941cd88..46471f0acfca6 100644 --- a/lib/private/Updater.php +++ b/lib/private/Updater.php @@ -284,8 +284,13 @@ private function doUpgrade($currentVersion, $installedVersion) { protected function doCoreUpgrade() { $this->emit('\OC\Updater', 'dbUpgradeBefore'); - // do the real upgrade - \OC_DB::updateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml'); + // execute core migrations + if (is_dir(\OC::$SERVERROOT."/core/Migrations")) { + $ms = new \OC\DB\MigrationService(); + $mc = $ms->buildConfiguration('core', \OC::$server->getDatabaseConnection()); + + $ms->migrate($mc, true); + } $this->emit('\OC\Updater', 'dbUpgrade'); } diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php index adf29601ac6d1..d2582c9ba413f 100644 --- a/lib/private/legacy/app.php +++ b/lib/private/legacy/app.php @@ -1122,8 +1122,14 @@ public static function updateApp($appId) { } $appData = self::getAppInfo($appId); self::executeRepairSteps($appId, $appData['repair-steps']['pre-migration']); - if (file_exists($appPath . '/appinfo/database.xml')) { - OC_DB::updateDbFromStructure($appPath . '/appinfo/database.xml'); + if (isset($appData['use-migrations']) && $appData['use-migrations'] === true) { + $ms = new \OC\DB\MigrationService(); + $mc = $ms->buildConfiguration($appId, \OC::$server->getDatabaseConnection()); + $ms->migrate($mc, true); + } else { + if (file_exists($appPath . '/appinfo/database.xml')) { + OC_DB::updateDbFromStructure($appPath . '/appinfo/database.xml'); + } } self::executeRepairSteps($appId, $appData['repair-steps']['post-migration']); self::setupLiveMigrations($appId, $appData['repair-steps']['live-migration']); From 6530c1d1e7c56f497d93b7d632df5a604ff58013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Wed, 30 Nov 2016 12:06:06 +0100 Subject: [PATCH 3/7] Testing MigrationService Signed-off-by: Lukas Reschke --- lib/private/DB/MigrationConfiguration.php | 11 ++++++-- tests/lib/DB/MigrationsTest.php | 32 +++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 tests/lib/DB/MigrationsTest.php diff --git a/lib/private/DB/MigrationConfiguration.php b/lib/private/DB/MigrationConfiguration.php index ab65ce1d6051f..cc8b592064f76 100644 --- a/lib/private/DB/MigrationConfiguration.php +++ b/lib/private/DB/MigrationConfiguration.php @@ -22,6 +22,7 @@ use Doctrine\DBAL\Migrations\Finder\MigrationFinderInterface; use Doctrine\DBAL\Migrations\OutputWriter; +use Doctrine\DBAL\Platforms\OraclePlatform; class MigrationConfiguration extends \Doctrine\DBAL\Migrations\Configuration\Configuration { @@ -33,12 +34,18 @@ function __construct(Connection $connection, OutputWriter $outputWriter = null, } public function setMigrationsColumnName($columnName) { - $columnName = $this->getConnection()->getDatabasePlatform()->quoteIdentifier($columnName); + $platform = $this->getConnection()->getDatabasePlatform(); + if ($platform instanceof OraclePlatform) { + $columnName = $platform->quoteIdentifier($columnName); + } parent::setMigrationsColumnName($columnName); } public function setMigrationsTableName($tableName) { - $tableName = $this->getConnection()->getDatabasePlatform()->quoteIdentifier($tableName); + $platform = $this->getConnection()->getDatabasePlatform(); + if ($platform instanceof OraclePlatform) { + $tableName = $platform->quoteIdentifier($tableName); + } parent::setMigrationsTableName($tableName); } diff --git a/tests/lib/DB/MigrationsTest.php b/tests/lib/DB/MigrationsTest.php new file mode 100644 index 0000000000000..860370adcfa54 --- /dev/null +++ b/tests/lib/DB/MigrationsTest.php @@ -0,0 +1,32 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + + +namespace Test\DB; + +use OC\DB\MigrationService; + +/** + * Class MigrationsTest + * + * @group DB + * + * @package Test\DB + */ +class MigrationsTest extends \Test\TestCase { + + public function testMigrationTableCreation() { + $m = new MigrationService(); + $appName = 'testing'; + $conf = $m->buildConfiguration($appName, \OC::$server->getDatabaseConnection()); + $this->assertTrue($conf->createMigrationTable()); + $this->assertFalse($conf->createMigrationTable()); + } + +} From 710bc06e185c62311bdafe0d7323b54772fea99a Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Fri, 9 Dec 2016 16:08:31 +0100 Subject: [PATCH 4/7] Check if migrations dir could be created Signed-off-by: Lukas Reschke --- lib/private/DB/MigrationService.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php index b9ea1395fadc3..abcccb125c61a 100644 --- a/lib/private/DB/MigrationService.php +++ b/lib/private/DB/MigrationService.php @@ -47,7 +47,9 @@ public function buildConfiguration($appName, $connection) { } if (!is_dir($migrationsPath)) { - mkdir($migrationsPath); + if (!mkdir($migrationsPath)) { + throw new \Exception("Could not create migration folder \"$migrationsPath\""); + }; } $prefix = $connection->getPrefix(); $mc = new MigrationConfiguration($connection); From 545b5d2506103318d84a7dafe203d6edcd2c2edb Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Fri, 9 Dec 2016 18:39:57 +0100 Subject: [PATCH 5/7] Fix "use-migrations" check in updateApp A bool is not always a bool... Signed-off-by: Lukas Reschke --- lib/private/Installer.php | 18 ++++-------------- lib/private/Setup/AbstractDatabase.php | 3 --- lib/private/legacy/app.php | 2 +- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/lib/private/Installer.php b/lib/private/Installer.php index 547052a496bf9..3073b8ce64126 100644 --- a/lib/private/Installer.php +++ b/lib/private/Installer.php @@ -486,25 +486,15 @@ public static function installShippedApp($app) { //install the database $appPath = OC_App::getAppPath($app); -<<<<<<< HEAD - if(is_file("$appPath/appinfo/database.xml")) { - try { - OC_DB::createDbFromStructure("$appPath/appinfo/database.xml"); - } catch (TableExistsException $e) { - throw new HintException( - 'Failed to enable app ' . $app, - 'Please ask for help via one of our support channels.', - 0, $e - ); -======= if (isset($info['use-migrations']) && $info['use-migrations'] === 'true') { $ms = new \OC\DB\MigrationService(); $mc = $ms->buildConfiguration($app, \OC::$server->getDatabaseConnection()); $ms->migrate($mc); } else { - if(is_file($appPath.'/appinfo/database.xml')) { - OC_DB::createDbFromStructure($appPath . '/appinfo/database.xml'); ->>>>>>> 87aa059... Integrate doctrine migrations with core and app upgrade + if (\OC::$server->getAppConfig()->getValue($info['id'], 'installed_version') === null) { + if (is_file($appPath . '/appinfo/database.xml')) { + OC_DB::createDbFromStructure($appPath . '/appinfo/database.xml'); + } } } diff --git a/lib/private/Setup/AbstractDatabase.php b/lib/private/Setup/AbstractDatabase.php index fbc39c4c341a0..cae46efd33932 100644 --- a/lib/private/Setup/AbstractDatabase.php +++ b/lib/private/Setup/AbstractDatabase.php @@ -26,12 +26,9 @@ */ namespace OC\Setup; -<<<<<<< HEAD use OC\AllConfig; use OC\DB\ConnectionFactory; -======= use OC\DB\MigrationService; ->>>>>>> 87aa059... Integrate doctrine migrations with core and app upgrade use OCP\IConfig; use OCP\IL10N; use OCP\ILogger; diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php index d2582c9ba413f..169fe96bcf54c 100644 --- a/lib/private/legacy/app.php +++ b/lib/private/legacy/app.php @@ -1122,7 +1122,7 @@ public static function updateApp($appId) { } $appData = self::getAppInfo($appId); self::executeRepairSteps($appId, $appData['repair-steps']['pre-migration']); - if (isset($appData['use-migrations']) && $appData['use-migrations'] === true) { + if (isset($appData['use-migrations']) && $appData['use-migrations'] === 'true') { $ms = new \OC\DB\MigrationService(); $mc = $ms->buildConfiguration($appId, \OC::$server->getDatabaseConnection()); $ms->migrate($mc, true); From a81666046f6030b3907a2fb53fc485f154d3cb09 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Thu, 22 Dec 2016 14:49:23 +0100 Subject: [PATCH 6/7] Update third-party ref Signed-off-by: Lukas Reschke --- 3rdparty | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty b/3rdparty index 32f3284a5ca0e..caeacf211cf4c 160000 --- a/3rdparty +++ b/3rdparty @@ -1 +1 @@ -Subproject commit 32f3284a5ca0e372baaf458dc22aed89e257178a +Subproject commit caeacf211cf4c264d770f2e10492528c6be9d9dd From 980f472d0cb05cafe98b57b0a5a4870638a87e32 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Thu, 22 Dec 2016 14:49:30 +0100 Subject: [PATCH 7/7] Correct codestyle issues Signed-off-by: Lukas Reschke --- core/Command/Db/Migrations/ExecuteCommand.php | 20 +++++++++---------- .../Command/Db/Migrations/GenerateCommand.php | 18 +++++++---------- core/Command/Db/Migrations/MigrateCommand.php | 18 +++++++---------- core/Command/Db/Migrations/StatusCommand.php | 17 +++++++--------- core/register_command.php | 8 ++++---- lib/composer/composer/autoload_classmap.php | 6 ++++++ lib/composer/composer/autoload_static.php | 6 ++++++ lib/private/DB/MigrationService.php | 5 +++-- tests/lib/DB/MigrationsTest.php | 3 --- 9 files changed, 49 insertions(+), 52 deletions(-) diff --git a/core/Command/Db/Migrations/ExecuteCommand.php b/core/Command/Db/Migrations/ExecuteCommand.php index 8f864e930de56..970aa9b91af59 100644 --- a/core/Command/Db/Migrations/ExecuteCommand.php +++ b/core/Command/Db/Migrations/ExecuteCommand.php @@ -21,26 +21,23 @@ namespace OC\Core\Command\Db\Migrations; - -use Doctrine\DBAL\Connection; use Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand as DBALExecuteCommand; use OC\DB\MigrationService; use OCP\IConfig; +use OCP\IDBConnection; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class ExecuteCommand extends DBALExecuteCommand { - - /** @var Connection */ - private $ocConnection; + /** @var IDBConnection */ + private $dbConnection; /** - * @param \OCP\IConfig $config + * @param IDBConnection $connection */ - public function __construct(IConfig $config, Connection $connection) { - $this->config = $config; - $this->ocConnection = $connection; + public function __construct(IDBConnection $connection) { + $this->dbConnection = $connection; parent::__construct(); } @@ -51,10 +48,11 @@ protected function configure() { parent::configure(); } - public function execute(InputInterface $input, OutputInterface $output) { + public function execute(InputInterface $input, + OutputInterface $output) { $appName = $input->getArgument('app'); $ms = new MigrationService(); - $mc = $ms->buildConfiguration($appName, $this->ocConnection); + $mc = $ms->buildConfiguration($appName, $this->dbConnection); $this->setMigrationConfiguration($mc); parent::execute($input, $output); diff --git a/core/Command/Db/Migrations/GenerateCommand.php b/core/Command/Db/Migrations/GenerateCommand.php index 3f738f81dddd9..ba56a6ee25ab4 100644 --- a/core/Command/Db/Migrations/GenerateCommand.php +++ b/core/Command/Db/Migrations/GenerateCommand.php @@ -21,26 +21,22 @@ namespace OC\Core\Command\Db\Migrations; - -use Doctrine\DBAL\Connection; use Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand as DBALGenerateCommand; use OC\DB\MigrationService; -use OCP\IConfig; +use OCP\IDBConnection; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class GenerateCommand extends DBALGenerateCommand { - - /** @var Connection */ - private $ocConnection; + /** @var IDBConnection */ + private $dbConnection; /** - * @param \OCP\IConfig $config + * @param IDBConnection $connection */ - public function __construct(IConfig $config, Connection $connection) { - $this->config = $config; - $this->ocConnection = $connection; + public function __construct(IDBConnection $connection) { + $this->dbConnection = $connection; parent::__construct(); } @@ -54,7 +50,7 @@ protected function configure() { public function execute(InputInterface $input, OutputInterface $output) { $appName = $input->getArgument('app'); $ms = new MigrationService(); - $mc = $ms->buildConfiguration($appName, $this->ocConnection); + $mc = $ms->buildConfiguration($appName, $this->dbConnection); $this->setMigrationConfiguration($mc); parent::execute($input, $output); diff --git a/core/Command/Db/Migrations/MigrateCommand.php b/core/Command/Db/Migrations/MigrateCommand.php index 5d6ff09c9b980..73966515f7476 100644 --- a/core/Command/Db/Migrations/MigrateCommand.php +++ b/core/Command/Db/Migrations/MigrateCommand.php @@ -21,26 +21,22 @@ namespace OC\Core\Command\Db\Migrations; - -use Doctrine\DBAL\Connection; use Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand as DBALMigrateCommand; use OC\DB\MigrationService; -use OCP\IConfig; +use OCP\IDBConnection; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class MigrateCommand extends DBALMigrateCommand { - - /** @var Connection */ - private $ocConnection; + /** @var IDBConnection */ + private $dbConnection; /** - * @param \OCP\IConfig $config + * @param IDBConnection $connection */ - public function __construct(IConfig $config, Connection $connection) { - $this->config = $config; - $this->ocConnection = $connection; + public function __construct(IDBConnection $connection) { + $this->dbConnection = $connection; parent::__construct(); } @@ -54,7 +50,7 @@ protected function configure() { public function execute(InputInterface $input, OutputInterface $output) { $appName = $input->getArgument('app'); $ms = new MigrationService(); - $mc = $ms->buildConfiguration($appName, $this->ocConnection); + $mc = $ms->buildConfiguration($appName, $this->dbConnection); $this->setMigrationConfiguration($mc); parent::execute($input, $output); diff --git a/core/Command/Db/Migrations/StatusCommand.php b/core/Command/Db/Migrations/StatusCommand.php index 6fd4420d6f20f..fceae2af7bc59 100644 --- a/core/Command/Db/Migrations/StatusCommand.php +++ b/core/Command/Db/Migrations/StatusCommand.php @@ -21,26 +21,23 @@ namespace OC\Core\Command\Db\Migrations; - -use Doctrine\DBAL\Connection; use Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand as DBALStatusCommand; use OC\DB\MigrationService; -use OCP\IConfig; +use OCP\IDBConnection; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class StatusCommand extends DBALStatusCommand { - /** @var Connection */ - private $ocConnection; + /** @var IDBConnection */ + private $dbConnection; /** - * @param \OCP\IConfig $config + * @param IDBConnection $connection */ - public function __construct(IConfig $config, Connection $connection) { - $this->config = $config; - $this->ocConnection = $connection; + public function __construct(IDBConnection $connection) { + $this->dbConnection = $connection; parent::__construct(); } @@ -54,7 +51,7 @@ protected function configure() { public function execute(InputInterface $input, OutputInterface $output) { $appName = $input->getArgument('app'); $ms = new MigrationService(); - $mc = $ms->buildConfiguration($appName, $this->ocConnection); + $mc = $ms->buildConfiguration($appName, $this->dbConnection); $this->setMigrationConfiguration($mc); parent::execute($input, $output); diff --git a/core/register_command.php b/core/register_command.php index 671274f7e503b..a99b7d7327045 100644 --- a/core/register_command.php +++ b/core/register_command.php @@ -84,10 +84,10 @@ $application->add(new OC\Core\Command\Db\GenerateChangeScript()); $application->add(new OC\Core\Command\Db\ConvertType(\OC::$server->getConfig(), new \OC\DB\ConnectionFactory(\OC::$server->getConfig()))); - $application->add(new OC\Core\Command\Db\Migrations\StatusCommand(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection())); - $application->add(new OC\Core\Command\Db\Migrations\MigrateCommand(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection())); - $application->add(new OC\Core\Command\Db\Migrations\GenerateCommand(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection())); - $application->add(new OC\Core\Command\Db\Migrations\ExecuteCommand(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection())); + $application->add(new OC\Core\Command\Db\Migrations\StatusCommand(\OC::$server->getDatabaseConnection())); + $application->add(new OC\Core\Command\Db\Migrations\MigrateCommand(\OC::$server->getDatabaseConnection())); + $application->add(new OC\Core\Command\Db\Migrations\GenerateCommand(\OC::$server->getDatabaseConnection())); + $application->add(new OC\Core\Command\Db\Migrations\ExecuteCommand(\OC::$server->getDatabaseConnection())); $application->add(new OC\Core\Command\Encryption\Disable(\OC::$server->getConfig())); $application->add(new OC\Core\Command\Encryption\Enable(\OC::$server->getConfig(), \OC::$server->getEncryptionManager())); diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 7a4cc6eaa8461..529934b7c6dec 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -374,6 +374,10 @@ 'OC\\Core\\Command\\Config\\System\\SetConfig' => $baseDir . '/core/Command/Config/System/SetConfig.php', 'OC\\Core\\Command\\Db\\ConvertType' => $baseDir . '/core/Command/Db/ConvertType.php', 'OC\\Core\\Command\\Db\\GenerateChangeScript' => $baseDir . '/core/Command/Db/GenerateChangeScript.php', + 'OC\\Core\\Command\\Db\\Migrations\\ExecuteCommand' => $baseDir . '/core/Command/Db/Migrations/ExecuteCommand.php', + 'OC\\Core\\Command\\Db\\Migrations\\GenerateCommand' => $baseDir . '/core/Command/Db/Migrations/GenerateCommand.php', + 'OC\\Core\\Command\\Db\\Migrations\\MigrateCommand' => $baseDir . '/core/Command/Db/Migrations/MigrateCommand.php', + 'OC\\Core\\Command\\Db\\Migrations\\StatusCommand' => $baseDir . '/core/Command/Db/Migrations/StatusCommand.php', 'OC\\Core\\Command\\Encryption\\ChangeKeyStorageRoot' => $baseDir . '/core/Command/Encryption/ChangeKeyStorageRoot.php', 'OC\\Core\\Command\\Encryption\\DecryptAll' => $baseDir . '/core/Command/Encryption/DecryptAll.php', 'OC\\Core\\Command\\Encryption\\Disable' => $baseDir . '/core/Command/Encryption/Disable.php', @@ -439,7 +443,9 @@ 'OC\\DB\\MDB2SchemaManager' => $baseDir . '/lib/private/DB/MDB2SchemaManager.php', 'OC\\DB\\MDB2SchemaReader' => $baseDir . '/lib/private/DB/MDB2SchemaReader.php', 'OC\\DB\\MDB2SchemaWriter' => $baseDir . '/lib/private/DB/MDB2SchemaWriter.php', + 'OC\\DB\\MigrationConfiguration' => $baseDir . '/lib/private/DB/MigrationConfiguration.php', 'OC\\DB\\MigrationException' => $baseDir . '/lib/private/DB/MigrationException.php', + 'OC\\DB\\MigrationService' => $baseDir . '/lib/private/DB/MigrationService.php', 'OC\\DB\\Migrator' => $baseDir . '/lib/private/DB/Migrator.php', 'OC\\DB\\MySQLMigrator' => $baseDir . '/lib/private/DB/MySQLMigrator.php', 'OC\\DB\\NoCheckMigrator' => $baseDir . '/lib/private/DB/NoCheckMigrator.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 6a063f0d8c790..66d9aa1ecf38c 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -404,6 +404,10 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Core\\Command\\Config\\System\\SetConfig' => __DIR__ . '/../../..' . '/core/Command/Config/System/SetConfig.php', 'OC\\Core\\Command\\Db\\ConvertType' => __DIR__ . '/../../..' . '/core/Command/Db/ConvertType.php', 'OC\\Core\\Command\\Db\\GenerateChangeScript' => __DIR__ . '/../../..' . '/core/Command/Db/GenerateChangeScript.php', + 'OC\\Core\\Command\\Db\\Migrations\\ExecuteCommand' => __DIR__ . '/../../..' . '/core/Command/Db/Migrations/ExecuteCommand.php', + 'OC\\Core\\Command\\Db\\Migrations\\GenerateCommand' => __DIR__ . '/../../..' . '/core/Command/Db/Migrations/GenerateCommand.php', + 'OC\\Core\\Command\\Db\\Migrations\\MigrateCommand' => __DIR__ . '/../../..' . '/core/Command/Db/Migrations/MigrateCommand.php', + 'OC\\Core\\Command\\Db\\Migrations\\StatusCommand' => __DIR__ . '/../../..' . '/core/Command/Db/Migrations/StatusCommand.php', 'OC\\Core\\Command\\Encryption\\ChangeKeyStorageRoot' => __DIR__ . '/../../..' . '/core/Command/Encryption/ChangeKeyStorageRoot.php', 'OC\\Core\\Command\\Encryption\\DecryptAll' => __DIR__ . '/../../..' . '/core/Command/Encryption/DecryptAll.php', 'OC\\Core\\Command\\Encryption\\Disable' => __DIR__ . '/../../..' . '/core/Command/Encryption/Disable.php', @@ -469,7 +473,9 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\DB\\MDB2SchemaManager' => __DIR__ . '/../../..' . '/lib/private/DB/MDB2SchemaManager.php', 'OC\\DB\\MDB2SchemaReader' => __DIR__ . '/../../..' . '/lib/private/DB/MDB2SchemaReader.php', 'OC\\DB\\MDB2SchemaWriter' => __DIR__ . '/../../..' . '/lib/private/DB/MDB2SchemaWriter.php', + 'OC\\DB\\MigrationConfiguration' => __DIR__ . '/../../..' . '/lib/private/DB/MigrationConfiguration.php', 'OC\\DB\\MigrationException' => __DIR__ . '/../../..' . '/lib/private/DB/MigrationException.php', + 'OC\\DB\\MigrationService' => __DIR__ . '/../../..' . '/lib/private/DB/MigrationService.php', 'OC\\DB\\Migrator' => __DIR__ . '/../../..' . '/lib/private/DB/Migrator.php', 'OC\\DB\\MySQLMigrator' => __DIR__ . '/../../..' . '/lib/private/DB/MySQLMigrator.php', 'OC\\DB\\NoCheckMigrator' => __DIR__ . '/../../..' . '/lib/private/DB/NoCheckMigrator.php', diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php index abcccb125c61a..87a64f192e33f 100644 --- a/lib/private/DB/MigrationService.php +++ b/lib/private/DB/MigrationService.php @@ -31,9 +31,10 @@ class MigrationService { /** * @param string $appName * @param IDBConnection $connection - * @return Configuration + * @return MigrationConfiguration + * @throws \Exception */ - public function buildConfiguration($appName, $connection) { + public function buildConfiguration($appName, IDBConnection $connection) { if ($appName === 'core') { $migrationsPath = \OC::$SERVERROOT . '/core/Migrations'; $migrationsNamespace = 'OC\\Migrations'; diff --git a/tests/lib/DB/MigrationsTest.php b/tests/lib/DB/MigrationsTest.php index 860370adcfa54..0ac82af0a801b 100644 --- a/tests/lib/DB/MigrationsTest.php +++ b/tests/lib/DB/MigrationsTest.php @@ -1,5 +1,4 @@ * This file is licensed under the Affero General Public License version 3 or @@ -20,7 +19,6 @@ * @package Test\DB */ class MigrationsTest extends \Test\TestCase { - public function testMigrationTableCreation() { $m = new MigrationService(); $appName = 'testing'; @@ -28,5 +26,4 @@ public function testMigrationTableCreation() { $this->assertTrue($conf->createMigrationTable()); $this->assertFalse($conf->createMigrationTable()); } - }