diff options
author | Joas Schilling <coding@schilljs.com> | 2017-06-02 13:54:09 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2017-07-05 13:01:19 +0200 |
commit | 194ef1a1715038c2193cee65a74372f07bc4eee6 (patch) | |
tree | 3e9f6120c64f85614cf926c2a7bd6286aaef3b88 /lib/private | |
parent | 183b1dbde3b5586e3bae0073f6f9c40414e7c6a6 (diff) | |
download | nextcloud-server-194ef1a1715038c2193cee65a74372f07bc4eee6.tar.gz nextcloud-server-194ef1a1715038c2193cee65a74372f07bc4eee6.zip |
Adjust the code to use our interface and abstract
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/DB/MigrationService.php | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php index 8a4980d1118..c81fe0f4332 100644 --- a/lib/private/DB/MigrationService.php +++ b/lib/private/DB/MigrationService.php @@ -22,10 +22,12 @@ namespace OC\DB; +use Doctrine\DBAL\Schema\Schema; use OC\IntegrityCheck\Helpers\AppLocator; use OC\Migration\SimpleOutput; use OCP\AppFramework\QueryException; use OCP\IDBConnection; +use OCP\Migration\IMigrationStep; use OCP\Migration\IOutput; use OCP\Migration\ISchemaMigration; use OCP\Migration\ISimpleMigration; @@ -373,23 +375,23 @@ class MigrationService { * @param string $version */ public function executeStep($version) { - - // FIXME our interface $instance = $this->createInstance($version); - if ($instance instanceof ISimpleMigration) { - $instance->run($this->output); - } - if ($instance instanceof ISqlMigration) { - $sqls = $instance->sql($this->connection); - foreach ($sqls as $s) { - $this->connection->executeQuery($s); - } + if (!$instance instanceof IMigrationStep) { + throw new \RuntimeException('Not a valid migration'); } - if ($instance instanceof ISchemaMigration) { - $toSchema = $this->connection->createSchema(); - $instance->changeSchema($toSchema, ['tablePrefix' => $this->connection->getPrefix()]); + + $instance->preSchemaChange($this->output); + + $toSchema = $instance->changeSchema(function() { + return $this->connection->createSchema(); + }, ['tablePrefix' => $this->connection->getPrefix()]); + + if ($toSchema instanceof Schema) { $this->connection->migrateToSchema($toSchema); } + + $instance->postSchemaChange($this->output); + $this->markAsExecuted($version); } |