diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2022-03-31 14:43:09 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-31 14:43:09 +0300 |
commit | eea05b05edb229a5834df43983ab6bd97de63e8e (patch) | |
tree | 948bee835b54bcb5428b140a3b8c46302587afa5 | |
parent | 87e079d2ad46cd68cc6693467aa0b855719f7585 (diff) | |
parent | b0b88059b8458bf12528d4fd86451613a3bb5759 (diff) |
Merge pull request #31737 from nextcloud/fix/oc_oauth2_migration
Wrap oauth2 migrations inside conditions
-rw-r--r-- | lib/private/Repair/Owncloud/MigrateOauthTables.php | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/lib/private/Repair/Owncloud/MigrateOauthTables.php b/lib/private/Repair/Owncloud/MigrateOauthTables.php index 274c2ee28db..4011a043f20 100644 --- a/lib/private/Repair/Owncloud/MigrateOauthTables.php +++ b/lib/private/Repair/Owncloud/MigrateOauthTables.php @@ -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', [ |