]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix migration of oc_credentials table
authorRobin Appelman <robin@icewind.nl>
Thu, 12 Nov 2020 14:03:21 +0000 (15:03 +0100)
committerRoeland Jago Douma <roeland@famdouma.nl>
Thu, 12 Nov 2020 14:56:34 +0000 (15:56 +0100)
Signed-off-by: Robin Appelman <robin@icewind.nl>
core/Migrations/Version20000Date20201109081918.php

index cea71148bc15de1dfa9f24d301d990ec1452b4ab..49bbd79b67d3c665f3b51ab310e7cb2b1bc67d26 100644 (file)
@@ -52,26 +52,28 @@ class Version20000Date20201109081918 extends SimpleMigrationStep {
                /** @var ISchemaWrapper $schema */
                $schema = $schemaClosure();
 
-               $table = $schema->createTable('storages_credentials');
-               $table->addColumn('id', Type::BIGINT, [
-                       'autoincrement' => true,
-                       'notnull' => true,
-                       'length' => 64,
-               ]);
-               $table->addColumn('user', Type::STRING, [
-                       'notnull' => false,
-                       'length' => 64,
-               ]);
-               $table->addColumn('identifier', Type::STRING, [
-                       'notnull' => true,
-                       'length' => 64,
-               ]);
-               $table->addColumn('credentials', Type::TEXT, [
-                       'notnull' => false,
-               ]);
-               $table->setPrimaryKey(['id']);
-               $table->addUniqueIndex(['user', 'identifier'], 'stocred_ui');
-               $table->addIndex(['user'], 'stocred_user');
+               if (!$schema->hasTable('storages_credentials')) {
+                       $table = $schema->createTable('storages_credentials');
+                       $table->addColumn('id', Type::BIGINT, [
+                               'autoincrement' => true,
+                               'notnull' => true,
+                               'length' => 64,
+                       ]);
+                       $table->addColumn('user', Type::STRING, [
+                               'notnull' => false,
+                               'length' => 64,
+                       ]);
+                       $table->addColumn('identifier', Type::STRING, [
+                               'notnull' => true,
+                               'length' => 64,
+                       ]);
+                       $table->addColumn('credentials', Type::TEXT, [
+                               'notnull' => false,
+                       ]);
+                       $table->setPrimaryKey(['id']);
+                       $table->addUniqueIndex(['user', 'identifier'], 'stocred_ui');
+                       $table->addIndex(['user'], 'stocred_user');
+               }
 
                return $schema;
        }
@@ -92,9 +94,9 @@ class Version20000Date20201109081918 extends SimpleMigrationStep {
 
                $insert = $this->connection->getQueryBuilder();
                $insert->insert('storages_credentials')
-                       ->setValue('user', $insert->createNamedParameter('user'))
-                       ->setValue('identifier', $insert->createNamedParameter('identifier'))
-                       ->setValue('credentials', $insert->createNamedParameter('credentials'));
+                       ->setValue('user', $insert->createParameter('user'))
+                       ->setValue('identifier', $insert->createParameter('identifier'))
+                       ->setValue('credentials', $insert->createParameter('credentials'));
 
                $result = $query->execute();
                while ($row = $result->fetch()) {