]> source.dussan.org Git - nextcloud-server.git/commitdiff
Wrap oauth2 migrations inside conditions 31737/head
authorLouis Chemineau <louis@chmn.me>
Thu, 31 Mar 2022 08:42:44 +0000 (10:42 +0200)
committerLouis Chemineau <louis@chmn.me>
Thu, 31 Mar 2022 08:42:44 +0000 (10:42 +0200)
Signed-off-by: Louis Chemineau <louis@chmn.me>
lib/private/Repair/Owncloud/MigrateOauthTables.php

index 274c2ee28dbad43a313e1dcd853e1979c4f503ea..4011a043f206a5f4e82b519265a617db16fcf743 100644 (file)
@@ -55,23 +55,34 @@ class MigrateOauthTables implements IRepairStep {
                $output->info("Update the oauth2_access_tokens table schema.");
                $schema = new SchemaWrapper($this->db);
                $table = $schema->getTable('oauth2_access_tokens');
-               $table->addColumn('hashed_code', 'string', [
-                       'notnull' => true,
-                       'length' => 128,
-               ]);
-               $table->addColumn('encrypted_token', 'string', [
-                       'notnull' => true,
-                       'length' => 786,
-               ]);
-               $table->addUniqueIndex(['hashed_code'], 'oauth2_access_hash_idx');
-               $table->addIndex(['client_id'], 'oauth2_access_client_id_idx');
-
+               if (!$table->hasColumn('hashed_code')) {
+                       $table->addColumn('hashed_code', 'string', [
+                               'notnull' => true,
+                               'length' => 128,
+                       ]);
+               }
+               if (!$table->hasColumn('encrypted_token')) {
+                       $table->addColumn('encrypted_token', 'string', [
+                               'notnull' => true,
+                               'length' => 786,
+                       ]);
+               }
+               if (!$table->hasIndex('oauth2_access_hash_idx')) {
+                       $table->addUniqueIndex(['hashed_code'], 'oauth2_access_hash_idx');
+               }
+               if (!$table->hasIndex('oauth2_access_client_id_idx')) {
+                       $table->addIndex(['client_id'], 'oauth2_access_client_id_idx');
+               }
 
                $output->info("Update the oauth2_clients table schema.");
                $schema = new SchemaWrapper($this->db);
                $table = $schema->getTable('oauth2_clients');
-               $table->getColumn('name')->setLength(64);
-               $table->dropColumn('allow_subdomains');
+               if ($table->getColumn('name')->getLength() !== 64) {
+                       $table->getColumn('name')->setLength(64);
+               }
+               if ($table->hasColumn('allow_subdomains')) {
+                       $table->dropColumn('allow_subdomains');
+               }
 
                if (!$schema->getTable('oauth2_clients')->hasColumn('client_identifier')) {
                        $table->addColumn('client_identifier', 'string', [