diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2018-01-17 14:55:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-17 14:55:18 +0100 |
commit | 414d6e2184734d158d1a2d65eeaf83ef523e1160 (patch) | |
tree | 748a8a11d44b92e7d190ba8fa7620805e1686242 /lib/public | |
parent | 9efdd684c4c1e1fcd653fe7b345d9d3659689742 (diff) | |
parent | ed999066e5e05fc569c1a9940e64aa13a916ddc8 (diff) | |
download | nextcloud-server-414d6e2184734d158d1a2d65eeaf83ef523e1160.tar.gz nextcloud-server-414d6e2184734d158d1a2d65eeaf83ef523e1160.zip |
Merge pull request #7915 from nextcloud/backport/7909/fix-migration-type-hints
Fix the type hints of migrations and correctly inject the wrapped sch…
Diffstat (limited to 'lib/public')
-rw-r--r-- | lib/public/DB/ISchemaWrapper.php | 92 | ||||
-rw-r--r-- | lib/public/Migration/BigIntMigration.php | 8 | ||||
-rw-r--r-- | lib/public/Migration/IMigrationStep.php | 10 | ||||
-rw-r--r-- | lib/public/Migration/SimpleMigrationStep.php | 10 |
4 files changed, 106 insertions, 14 deletions
diff --git a/lib/public/DB/ISchemaWrapper.php b/lib/public/DB/ISchemaWrapper.php new file mode 100644 index 00000000000..b29831dbc2e --- /dev/null +++ b/lib/public/DB/ISchemaWrapper.php @@ -0,0 +1,92 @@ +<?php +/** + * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\DB; + +/** + * Interface ISchemaWrapper + * + * @package OCP\DB + * @since 13.0.0 + */ +interface ISchemaWrapper { + + /** + * @param string $tableName + * + * @return \Doctrine\DBAL\Schema\Table + * @throws \Doctrine\DBAL\Schema\SchemaException + * @since 13.0.0 + */ + public function getTable($tableName); + + /** + * Does this schema have a table with the given name? + * + * @param string $tableName Prefix is automatically prepended + * + * @return boolean + * @since 13.0.0 + */ + public function hasTable($tableName); + + /** + * Creates a new table. + * + * @param string $tableName Prefix is automatically prepended + * @return \Doctrine\DBAL\Schema\Table + * @since 13.0.0 + */ + public function createTable($tableName); + + /** + * Drops a table from the schema. + * + * @param string $tableName Prefix is automatically prepended + * @return \Doctrine\DBAL\Schema\Schema + * @since 13.0.0 + */ + public function dropTable($tableName); + + /** + * Gets all tables of this schema. + * + * @return \Doctrine\DBAL\Schema\Table[] + * @since 13.0.0 + */ + public function getTables(); + + /** + * Gets all table names, prefixed with table prefix + * + * @return array + * @since 13.0.0 + */ + public function getTableNames(); + + /** + * Gets all table names + * + * @return array + * @since 13.0.0 + */ + public function getTableNamesWithoutPrefix(); +} diff --git a/lib/public/Migration/BigIntMigration.php b/lib/public/Migration/BigIntMigration.php index 9e6003714e5..41c48f2181a 100644 --- a/lib/public/Migration/BigIntMigration.php +++ b/lib/public/Migration/BigIntMigration.php @@ -23,8 +23,8 @@ namespace OCP\Migration; -use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Types\Type; +use OCP\DB\ISchemaWrapper; /** * @since 13.0.0 @@ -40,13 +40,13 @@ abstract class BigIntMigration extends SimpleMigrationStep { /** * @param IOutput $output - * @param \Closure $schemaClosure The `\Closure` returns a `Schema` + * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @param array $options - * @return null|Schema + * @return null|ISchemaWrapper * @since 13.0.0 */ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { - /** @var Schema $schema */ + /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); $tables = $this->getColumnsByTable(); diff --git a/lib/public/Migration/IMigrationStep.php b/lib/public/Migration/IMigrationStep.php index 11b92ecf0cf..e12d962683e 100644 --- a/lib/public/Migration/IMigrationStep.php +++ b/lib/public/Migration/IMigrationStep.php @@ -23,7 +23,7 @@ namespace OCP\Migration; -use Doctrine\DBAL\Schema\Schema; +use OCP\DB\ISchemaWrapper; /** * @since 13.0.0 @@ -32,7 +32,7 @@ interface IMigrationStep { /** * @param IOutput $output - * @param \Closure $schemaClosure The `\Closure` returns a `Schema` + * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @param array $options * @since 13.0.0 */ @@ -40,16 +40,16 @@ interface IMigrationStep { /** * @param IOutput $output - * @param \Closure $schemaClosure The `\Closure` returns a `Schema` + * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @param array $options - * @return null|Schema + * @return null|ISchemaWrapper * @since 13.0.0 */ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options); /** * @param IOutput $output - * @param \Closure $schemaClosure The `\Closure` returns a `Schema` + * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @param array $options * @since 13.0.0 */ diff --git a/lib/public/Migration/SimpleMigrationStep.php b/lib/public/Migration/SimpleMigrationStep.php index 58c68064484..da46c687644 100644 --- a/lib/public/Migration/SimpleMigrationStep.php +++ b/lib/public/Migration/SimpleMigrationStep.php @@ -23,7 +23,7 @@ namespace OCP\Migration; -use Doctrine\DBAL\Schema\Schema; +use OCP\DB\ISchemaWrapper; /** * @since 13.0.0 @@ -32,7 +32,7 @@ abstract class SimpleMigrationStep implements IMigrationStep { /** * @param IOutput $output - * @param \Closure $schemaClosure The `\Closure` returns a `Schema` + * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @param array $options * @since 13.0.0 */ @@ -41,9 +41,9 @@ abstract class SimpleMigrationStep implements IMigrationStep { /** * @param IOutput $output - * @param \Closure $schemaClosure The `\Closure` returns a `Schema` + * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @param array $options - * @return null|Schema + * @return null|ISchemaWrapper * @since 13.0.0 */ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { @@ -52,7 +52,7 @@ abstract class SimpleMigrationStep implements IMigrationStep { /** * @param IOutput $output - * @param \Closure $schemaClosure The `\Closure` returns a `Schema` + * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @param array $options * @since 13.0.0 */ |