]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(owncloud): Fix ownCloud migration with oauth2 app backport/49076/stable29 49085/head
authorJoas Schilling <coding@schilljs.com>
Mon, 4 Nov 2024 13:16:40 +0000 (14:16 +0100)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Mon, 4 Nov 2024 20:36:20 +0000 (20:36 +0000)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/Repair/Owncloud/MigrateOauthTables.php

index ae2b46e19496c06e3a86d26b2aee594cbfdd4c53..8282db6bd0b2cc1e1a2b582b69c3ffab98314156 100644 (file)
@@ -51,8 +51,7 @@ class MigrateOauthTables implements IRepairStep {
                        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', [
@@ -73,8 +72,7 @@ class MigrateOauthTables implements IRepairStep {
                        $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
@@ -118,7 +116,8 @@ class MigrateOauthTables implements IRepairStep {
 
                $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.
@@ -137,8 +136,7 @@ class MigrateOauthTables implements IRepairStep {
                                        ->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());