-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Poc doctrine migrations #2827
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
Poc doctrine migrations #2827
Changes from all commits
c02e880
f20a15d
6530c1d
710bc06
545b5d2
a816660
980f472
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| <?php | ||
| /** | ||
| * @author Thomas Müller <thomas.mueller@tmit.eu> | ||
| * | ||
| * @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 <http://www.gnu.org/licenses/> | ||
| * | ||
| */ | ||
|
|
||
| namespace OC\Core\Command\Db\Migrations; | ||
|
|
||
| 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 IDBConnection */ | ||
| private $dbConnection; | ||
|
|
||
| /** | ||
| * @param IDBConnection $connection | ||
| */ | ||
| public function __construct(IDBConnection $connection) { | ||
| $this->dbConnection = $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'); | ||
| $ms = new MigrationService(); | ||
| $mc = $ms->buildConfiguration($appName, $this->dbConnection); | ||
| $this->setMigrationConfiguration($mc); | ||
|
|
||
| parent::execute($input, $output); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| <?php | ||
| /** | ||
| * @author Thomas Müller <thomas.mueller@tmit.eu> | ||
| * | ||
| * @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 <http://www.gnu.org/licenses/> | ||
| * | ||
| */ | ||
|
|
||
| namespace OC\Core\Command\Db\Migrations; | ||
|
|
||
| use Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand as DBALGenerateCommand; | ||
| use OC\DB\MigrationService; | ||
| 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 IDBConnection */ | ||
| private $dbConnection; | ||
|
|
||
| /** | ||
| * @param IDBConnection $connection | ||
| */ | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PHPDoc should be adjusted |
||
| public function __construct(IDBConnection $connection) { | ||
| $this->dbConnection = $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'); | ||
| $ms = new MigrationService(); | ||
| $mc = $ms->buildConfiguration($appName, $this->dbConnection); | ||
| $this->setMigrationConfiguration($mc); | ||
|
|
||
| parent::execute($input, $output); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| <?php | ||
| /** | ||
| * @author Thomas Müller <thomas.mueller@tmit.eu> | ||
| * | ||
| * @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 <http://www.gnu.org/licenses/> | ||
| * | ||
| */ | ||
|
|
||
| namespace OC\Core\Command\Db\Migrations; | ||
|
|
||
| use Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand as DBALMigrateCommand; | ||
| use OC\DB\MigrationService; | ||
| 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 IDBConnection */ | ||
| private $dbConnection; | ||
|
|
||
| /** | ||
| * @param IDBConnection $connection | ||
| */ | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PHPDoc should be adjusted |
||
| public function __construct(IDBConnection $connection) { | ||
| $this->dbConnection = $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'); | ||
| $ms = new MigrationService(); | ||
| $mc = $ms->buildConfiguration($appName, $this->dbConnection); | ||
| $this->setMigrationConfiguration($mc); | ||
|
|
||
| parent::execute($input, $output); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| <?php | ||
| /** | ||
| * @author Thomas Müller <thomas.mueller@tmit.eu> | ||
| * | ||
| * @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 <http://www.gnu.org/licenses/> | ||
| * | ||
| */ | ||
|
|
||
| namespace OC\Core\Command\Db\Migrations; | ||
|
|
||
| use Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand as DBALStatusCommand; | ||
| use OC\DB\MigrationService; | ||
| 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 IDBConnection */ | ||
| private $dbConnection; | ||
|
|
||
| /** | ||
| * @param IDBConnection $connection | ||
| */ | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PHPDoc should be adjusted |
||
| public function __construct(IDBConnection $connection) { | ||
| $this->dbConnection = $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'); | ||
| $ms = new MigrationService(); | ||
| $mc = $ms->buildConfiguration($appName, $this->dbConnection); | ||
| $this->setMigrationConfiguration($mc); | ||
|
|
||
| parent::execute($input, $output); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. $schema is not in PHPDoc |
||
| 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); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| <?php | ||
| /** | ||
| * @author Thomas Müller <thomas.mueller@tmit.eu> | ||
| * | ||
| * @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 <http://www.gnu.org/licenses/> | ||
| * | ||
| */ | ||
| namespace OC\DB; | ||
|
|
||
| use Doctrine\DBAL\Migrations\Finder\MigrationFinderInterface; | ||
| use Doctrine\DBAL\Migrations\OutputWriter; | ||
| use Doctrine\DBAL\Platforms\OraclePlatform; | ||
|
|
||
| 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) { | ||
| $platform = $this->getConnection()->getDatabasePlatform(); | ||
| if ($platform instanceof OraclePlatform) { | ||
| $columnName = $platform->quoteIdentifier($columnName); | ||
| } | ||
| parent::setMigrationsColumnName($columnName); | ||
| } | ||
|
|
||
| public function setMigrationsTableName($tableName) { | ||
| $platform = $this->getConnection()->getDatabasePlatform(); | ||
| if ($platform instanceof OraclePlatform) { | ||
| $tableName = $platform->quoteIdentifier($tableName); | ||
| } | ||
| parent::setMigrationsTableName($tableName); | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PHPDoc should be adjusted.