diff options
author | Joas Schilling <coding@schilljs.com> | 2018-01-17 11:35:20 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2018-01-17 11:37:36 +0100 |
commit | 4a5282ba2191059a356540165ac43dcb972eda8d (patch) | |
tree | bcf8e51b550f70f45bee4f652288ad00f57847f1 /lib/private | |
parent | 6e95bd7a518f587836124e7cb3a3762fb4a62e8c (diff) | |
download | nextcloud-server-4a5282ba2191059a356540165ac43dcb972eda8d.tar.gz nextcloud-server-4a5282ba2191059a356540165ac43dcb972eda8d.zip |
Fix the type hints of migrations and correctly inject the wrapped schema into migrations
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/DB/MigrationService.php | 4 | ||||
-rw-r--r-- | lib/private/DB/SchemaWrapper.php | 33 |
2 files changed, 16 insertions, 21 deletions
diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php index cbe5bd9b957..57283fbe8b5 100644 --- a/lib/private/DB/MigrationService.php +++ b/lib/private/DB/MigrationService.php @@ -423,7 +423,7 @@ class MigrationService { } $instance->preSchemaChange($this->output, function() { - return $this->connection->createSchema(); + return new SchemaWrapper($this->connection); }, ['tablePrefix' => $this->connection->getPrefix()]); $toSchema = $instance->changeSchema($this->output, function() { @@ -436,7 +436,7 @@ class MigrationService { } $instance->postSchemaChange($this->output, function() { - return $this->connection->createSchema(); + return new SchemaWrapper($this->connection); }, ['tablePrefix' => $this->connection->getPrefix()]); $this->markAsExecuted($version); diff --git a/lib/private/DB/SchemaWrapper.php b/lib/private/DB/SchemaWrapper.php index 2a0660b2a88..4f05b7b00ef 100644 --- a/lib/private/DB/SchemaWrapper.php +++ b/lib/private/DB/SchemaWrapper.php @@ -25,9 +25,10 @@ namespace OC\DB; use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Schema\Schema; +use OCP\DB\ISchemaWrapper; use OCP\IDBConnection; -class SchemaWrapper { +class SchemaWrapper implements ISchemaWrapper { /** @var IDBConnection|Connection */ protected $connection; @@ -76,6 +77,13 @@ class SchemaWrapper { // Overwritten methods /** + * @return array + */ + public function getTableNames() { + return $this->schema->getTableNames(); + } + + /** * @param string $tableName * * @return \Doctrine\DBAL\Schema\Table @@ -107,19 +115,6 @@ class SchemaWrapper { } /** - * Renames a table. - * - * @param string $oldTableName - * @param string $newTableName - * - * @return \Doctrine\DBAL\Schema\Schema - * @throws DBALException - */ - public function renameTable($oldTableName, $newTableName) { - throw new DBALException('Renaming tables is not supported. Please create and drop the tables manually.'); - } - - /** * Drops a table from the schema. * * @param string $tableName @@ -131,11 +126,11 @@ class SchemaWrapper { } /** - * @param string $name - * @param array $arguments - * @return mixed + * Gets all tables of this schema. + * + * @return \Doctrine\DBAL\Schema\Table[] */ - public function __call($name, $arguments) { - return call_user_func_array([$this->schema, $name], $arguments); + public function getTables() { + return $this->schema->getTables(); } } |