Skip to content

Commit

Permalink
fix(owncloud): Fix ownCloud migration with oauth2 app
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen authored and backportbot[bot] committed Nov 4, 2024
1 parent 845be23 commit 3f5770a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/private/Repair/Owncloud/MigrateOauthTables.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public function run(IOutput $output) {
return;
}

$output->info("Update the oauth2_access_tokens table schema.");
$schema = new SchemaWrapper($this->db);
$output->info('Update the oauth2_access_tokens table schema.');
$table = $schema->getTable('oauth2_access_tokens');
if (!$table->hasColumn('hashed_code')) {
$table->addColumn('hashed_code', 'string', [
Expand All @@ -73,8 +72,7 @@ public function run(IOutput $output) {
$table->addIndex(['client_id'], 'oauth2_access_client_id_idx');
}

$output->info("Update the oauth2_clients table schema.");
$schema = new SchemaWrapper($this->db);
$output->info('Update the oauth2_clients table schema.');
$table = $schema->getTable('oauth2_clients');
if ($table->getColumn('name')->getLength() !== 64) {
// shorten existing values before resizing the column
Expand Down Expand Up @@ -118,7 +116,8 @@ public function run(IOutput $output) {

$this->db->migrateToSchema($schema->getWrappedSchema());


// Regenerate schema after migrating to it
$schema = new SchemaWrapper($this->db);
if ($schema->getTable('oauth2_clients')->hasColumn('identifier')) {
$output->info("Move identifier column's data to the new client_identifier column.");
// 1. Fetch all [id, identifier] couple.
Expand All @@ -137,8 +136,7 @@ public function run(IOutput $output) {
->executeStatement();
}

$output->info("Drop the identifier column.");
$schema = new SchemaWrapper($this->db);
$output->info('Drop the identifier column.');
$table = $schema->getTable('oauth2_clients');
$table->dropColumn('identifier');
$this->db->migrateToSchema($schema->getWrappedSchema());
Expand Down

0 comments on commit 3f5770a

Please sign in to comment.