Passed
Push — master ( 87e079...eea05b )
by Joas
14:52 queued 23s
created
lib/private/Repair/Owncloud/MigrateOauthTables.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -28,97 +28,97 @@
 block discarded – undo
28 28
 
29 29
 class MigrateOauthTables implements IRepairStep {
30 30
 
31
-	/** @var Connection */
32
-	protected $db;
31
+    /** @var Connection */
32
+    protected $db;
33 33
 
34
-	/**
35
-	 * @param Connection $db
36
-	 */
37
-	public function __construct(Connection $db) {
38
-		$this->db = $db;
39
-	}
34
+    /**
35
+     * @param Connection $db
36
+     */
37
+    public function __construct(Connection $db) {
38
+        $this->db = $db;
39
+    }
40 40
 
41
-	/**
42
-	 * @return string
43
-	 */
44
-	public function getName() {
45
-		return 'Migrate oauth2_clients table to nextcloud schema';
46
-	}
41
+    /**
42
+     * @return string
43
+     */
44
+    public function getName() {
45
+        return 'Migrate oauth2_clients table to nextcloud schema';
46
+    }
47 47
 
48
-	public function run(IOutput $output) {
49
-		$schema = new SchemaWrapper($this->db);
50
-		if (!$schema->hasTable('oauth2_clients')) {
51
-			$output->info("oauth2_clients table does not exist.");
52
-			return;
53
-		}
48
+    public function run(IOutput $output) {
49
+        $schema = new SchemaWrapper($this->db);
50
+        if (!$schema->hasTable('oauth2_clients')) {
51
+            $output->info("oauth2_clients table does not exist.");
52
+            return;
53
+        }
54 54
 
55
-		$output->info("Update the oauth2_access_tokens table schema.");
56
-		$schema = new SchemaWrapper($this->db);
57
-		$table = $schema->getTable('oauth2_access_tokens');
58
-		if (!$table->hasColumn('hashed_code')) {
59
-			$table->addColumn('hashed_code', 'string', [
60
-				'notnull' => true,
61
-				'length' => 128,
62
-			]);
63
-		}
64
-		if (!$table->hasColumn('encrypted_token')) {
65
-			$table->addColumn('encrypted_token', 'string', [
66
-				'notnull' => true,
67
-				'length' => 786,
68
-			]);
69
-		}
70
-		if (!$table->hasIndex('oauth2_access_hash_idx')) {
71
-			$table->addUniqueIndex(['hashed_code'], 'oauth2_access_hash_idx');
72
-		}
73
-		if (!$table->hasIndex('oauth2_access_client_id_idx')) {
74
-			$table->addIndex(['client_id'], 'oauth2_access_client_id_idx');
75
-		}
55
+        $output->info("Update the oauth2_access_tokens table schema.");
56
+        $schema = new SchemaWrapper($this->db);
57
+        $table = $schema->getTable('oauth2_access_tokens');
58
+        if (!$table->hasColumn('hashed_code')) {
59
+            $table->addColumn('hashed_code', 'string', [
60
+                'notnull' => true,
61
+                'length' => 128,
62
+            ]);
63
+        }
64
+        if (!$table->hasColumn('encrypted_token')) {
65
+            $table->addColumn('encrypted_token', 'string', [
66
+                'notnull' => true,
67
+                'length' => 786,
68
+            ]);
69
+        }
70
+        if (!$table->hasIndex('oauth2_access_hash_idx')) {
71
+            $table->addUniqueIndex(['hashed_code'], 'oauth2_access_hash_idx');
72
+        }
73
+        if (!$table->hasIndex('oauth2_access_client_id_idx')) {
74
+            $table->addIndex(['client_id'], 'oauth2_access_client_id_idx');
75
+        }
76 76
 
77
-		$output->info("Update the oauth2_clients table schema.");
78
-		$schema = new SchemaWrapper($this->db);
79
-		$table = $schema->getTable('oauth2_clients');
80
-		if ($table->getColumn('name')->getLength() !== 64) {
81
-			$table->getColumn('name')->setLength(64);
82
-		}
83
-		if ($table->hasColumn('allow_subdomains')) {
84
-			$table->dropColumn('allow_subdomains');
85
-		}
77
+        $output->info("Update the oauth2_clients table schema.");
78
+        $schema = new SchemaWrapper($this->db);
79
+        $table = $schema->getTable('oauth2_clients');
80
+        if ($table->getColumn('name')->getLength() !== 64) {
81
+            $table->getColumn('name')->setLength(64);
82
+        }
83
+        if ($table->hasColumn('allow_subdomains')) {
84
+            $table->dropColumn('allow_subdomains');
85
+        }
86 86
 
87
-		if (!$schema->getTable('oauth2_clients')->hasColumn('client_identifier')) {
88
-			$table->addColumn('client_identifier', 'string', [
89
-				'notnull' => true,
90
-				'length' => 64,
91
-				'default' => ''
92
-			]);
93
-			$table->addIndex(['client_identifier'], 'oauth2_client_id_idx');
94
-		}
87
+        if (!$schema->getTable('oauth2_clients')->hasColumn('client_identifier')) {
88
+            $table->addColumn('client_identifier', 'string', [
89
+                'notnull' => true,
90
+                'length' => 64,
91
+                'default' => ''
92
+            ]);
93
+            $table->addIndex(['client_identifier'], 'oauth2_client_id_idx');
94
+        }
95 95
 
96
-		$this->db->migrateToSchema($schema->getWrappedSchema());
96
+        $this->db->migrateToSchema($schema->getWrappedSchema());
97 97
 
98 98
 
99
-		if ($schema->getTable('oauth2_clients')->hasColumn('identifier')) {
100
-			$output->info("Move identifier column's data to the new client_identifier column.");
101
-			// 1. Fetch all [id, identifier] couple.
102
-			$selectQuery = $this->db->getQueryBuilder();
103
-			$selectQuery->select('id', 'identifier')->from('oauth2_clients');
104
-			$result = $selectQuery->executeQuery();
105
-			$identifiers = $result->fetchAll();
106
-			$result->closeCursor();
99
+        if ($schema->getTable('oauth2_clients')->hasColumn('identifier')) {
100
+            $output->info("Move identifier column's data to the new client_identifier column.");
101
+            // 1. Fetch all [id, identifier] couple.
102
+            $selectQuery = $this->db->getQueryBuilder();
103
+            $selectQuery->select('id', 'identifier')->from('oauth2_clients');
104
+            $result = $selectQuery->executeQuery();
105
+            $identifiers = $result->fetchAll();
106
+            $result->closeCursor();
107 107
 
108
-			// 2. Insert them into the client_identifier column.
109
-			foreach ($identifiers as ["id" => $id, "identifier" => $clientIdentifier]) {
110
-				$insertQuery = $this->db->getQueryBuilder();
111
-				$insertQuery->update('oauth2_clients')
112
-					->set('client_identifier', $insertQuery->createNamedParameter($clientIdentifier, IQueryBuilder::PARAM_STR))
113
-					->where($insertQuery->expr()->eq('id', $insertQuery->createNamedParameter($id, IQueryBuilder::PARAM_INT)))
114
-					->executeStatement();
115
-			}
108
+            // 2. Insert them into the client_identifier column.
109
+            foreach ($identifiers as ["id" => $id, "identifier" => $clientIdentifier]) {
110
+                $insertQuery = $this->db->getQueryBuilder();
111
+                $insertQuery->update('oauth2_clients')
112
+                    ->set('client_identifier', $insertQuery->createNamedParameter($clientIdentifier, IQueryBuilder::PARAM_STR))
113
+                    ->where($insertQuery->expr()->eq('id', $insertQuery->createNamedParameter($id, IQueryBuilder::PARAM_INT)))
114
+                    ->executeStatement();
115
+            }
116 116
 
117
-			$output->info("Drop the identifier column.");
118
-			$schema = new SchemaWrapper($this->db);
119
-			$table = $schema->getTable('oauth2_clients');
120
-			$table->dropColumn('identifier');
121
-			$this->db->migrateToSchema($schema->getWrappedSchema());
122
-		}
123
-	}
117
+            $output->info("Drop the identifier column.");
118
+            $schema = new SchemaWrapper($this->db);
119
+            $table = $schema->getTable('oauth2_clients');
120
+            $table->dropColumn('identifier');
121
+            $this->db->migrateToSchema($schema->getWrappedSchema());
122
+        }
123
+    }
124 124
 }
Please login to merge, or discard this patch.