Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable23] Wrap oauth2 migrations inside conditions #31774

Merged
merged 1 commit into from
Mar 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 24 additions & 13 deletions lib/private/Repair/Owncloud/MigrateOauthTables.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,34 @@ public function run(IOutput $output) {
$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', [
Expand Down