Passed
Push — master ( 41216e...365569 )
by Roeland
14:51 queued 11s
created
core/Command/Db/AddMissingIndices.php 1 patch
Indentation   +263 added lines, -263 removed lines patch added patch discarded remove patch
@@ -52,267 +52,267 @@
 block discarded – undo
52 52
  */
53 53
 class AddMissingIndices extends Command {
54 54
 
55
-	/** @var Connection */
56
-	private $connection;
57
-
58
-	/** @var EventDispatcherInterface */
59
-	private $dispatcher;
60
-
61
-	public function __construct(Connection $connection, EventDispatcherInterface $dispatcher) {
62
-		parent::__construct();
63
-
64
-		$this->connection = $connection;
65
-		$this->dispatcher = $dispatcher;
66
-	}
67
-
68
-	protected function configure() {
69
-		$this
70
-			->setName('db:add-missing-indices')
71
-			->setDescription('Add missing indices to the database tables');
72
-	}
73
-
74
-	protected function execute(InputInterface $input, OutputInterface $output): int {
75
-		$this->addCoreIndexes($output);
76
-
77
-		// Dispatch event so apps can also update indexes if needed
78
-		$event = new GenericEvent($output);
79
-		$this->dispatcher->dispatch(IDBConnection::ADD_MISSING_INDEXES_EVENT, $event);
80
-		return 0;
81
-	}
82
-
83
-	/**
84
-	 * add missing indices to the share table
85
-	 *
86
-	 * @param OutputInterface $output
87
-	 * @throws \Doctrine\DBAL\Schema\SchemaException
88
-	 */
89
-	private function addCoreIndexes(OutputInterface $output) {
90
-		$output->writeln('<info>Check indices of the share table.</info>');
91
-
92
-		$schema = new SchemaWrapper($this->connection);
93
-		$updated = false;
94
-
95
-		if ($schema->hasTable('share')) {
96
-			$table = $schema->getTable('share');
97
-			if (!$table->hasIndex('share_with_index')) {
98
-				$output->writeln('<info>Adding additional share_with index to the share table, this can take some time...</info>');
99
-				$table->addIndex(['share_with'], 'share_with_index');
100
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
101
-				$updated = true;
102
-				$output->writeln('<info>Share table updated successfully.</info>');
103
-			}
104
-
105
-			if (!$table->hasIndex('parent_index')) {
106
-				$output->writeln('<info>Adding additional parent index to the share table, this can take some time...</info>');
107
-				$table->addIndex(['parent'], 'parent_index');
108
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
109
-				$updated = true;
110
-				$output->writeln('<info>Share table updated successfully.</info>');
111
-			}
112
-
113
-			if (!$table->hasIndex('owner_index')) {
114
-				$output->writeln('<info>Adding additional owner index to the share table, this can take some time...</info>');
115
-				$table->addIndex(['uid_owner'], 'owner_index');
116
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
117
-				$updated = true;
118
-				$output->writeln('<info>Share table updated successfully.</info>');
119
-			}
120
-
121
-			if (!$table->hasIndex('initiator_index')) {
122
-				$output->writeln('<info>Adding additional initiator index to the share table, this can take some time...</info>');
123
-				$table->addIndex(['uid_initiator'], 'initiator_index');
124
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
125
-				$updated = true;
126
-				$output->writeln('<info>Share table updated successfully.</info>');
127
-			}
128
-		}
129
-
130
-		$output->writeln('<info>Check indices of the filecache table.</info>');
131
-		if ($schema->hasTable('filecache')) {
132
-			$table = $schema->getTable('filecache');
133
-			if (!$table->hasIndex('fs_mtime')) {
134
-				$output->writeln('<info>Adding additional mtime index to the filecache table, this can take some time...</info>');
135
-				$table->addIndex(['mtime'], 'fs_mtime');
136
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
137
-				$updated = true;
138
-				$output->writeln('<info>Filecache table updated successfully.</info>');
139
-			}
140
-			if (!$table->hasIndex('fs_size')) {
141
-				$output->writeln('<info>Adding additional size index to the filecache table, this can take some time...</info>');
142
-				$table->addIndex(['size'], 'fs_size');
143
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
144
-				$updated = true;
145
-				$output->writeln('<info>Filecache table updated successfully.</info>');
146
-			}
147
-		}
148
-
149
-		$output->writeln('<info>Check indices of the twofactor_providers table.</info>');
150
-		if ($schema->hasTable('twofactor_providers')) {
151
-			$table = $schema->getTable('twofactor_providers');
152
-			if (!$table->hasIndex('twofactor_providers_uid')) {
153
-				$output->writeln('<info>Adding additional twofactor_providers_uid index to the twofactor_providers table, this can take some time...</info>');
154
-				$table->addIndex(['uid'], 'twofactor_providers_uid');
155
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
156
-				$updated = true;
157
-				$output->writeln('<info>Twofactor_providers table updated successfully.</info>');
158
-			}
159
-		}
160
-
161
-		$output->writeln('<info>Check indices of the login_flow_v2 table.</info>');
162
-		if ($schema->hasTable('login_flow_v2')) {
163
-			$table = $schema->getTable('login_flow_v2');
164
-			if (!$table->hasIndex('poll_token')) {
165
-				$output->writeln('<info>Adding additional indeces to the login_flow_v2 table, this can take some time...</info>');
166
-
167
-				foreach ($table->getIndexes() as $index) {
168
-					$columns = $index->getColumns();
169
-					if ($columns === ['poll_token'] ||
170
-						$columns === ['login_token'] ||
171
-						$columns === ['timestamp']) {
172
-						$table->dropIndex($index->getName());
173
-					}
174
-				}
175
-
176
-				$table->addUniqueIndex(['poll_token'], 'poll_token');
177
-				$table->addUniqueIndex(['login_token'], 'login_token');
178
-				$table->addIndex(['timestamp'], 'timestamp');
179
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
180
-				$updated = true;
181
-				$output->writeln('<info>login_flow_v2 table updated successfully.</info>');
182
-			}
183
-		}
184
-
185
-		$output->writeln('<info>Check indices of the whats_new table.</info>');
186
-		if ($schema->hasTable('whats_new')) {
187
-			$table = $schema->getTable('whats_new');
188
-			if (!$table->hasIndex('version')) {
189
-				$output->writeln('<info>Adding version index to the whats_new table, this can take some time...</info>');
190
-
191
-				foreach ($table->getIndexes() as $index) {
192
-					if ($index->getColumns() === ['version']) {
193
-						$table->dropIndex($index->getName());
194
-					}
195
-				}
196
-
197
-				$table->addUniqueIndex(['version'], 'version');
198
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
199
-				$updated = true;
200
-				$output->writeln('<info>whats_new table updated successfully.</info>');
201
-			}
202
-		}
203
-
204
-		$output->writeln('<info>Check indices of the cards table.</info>');
205
-		$cardsUpdated = false;
206
-		if ($schema->hasTable('cards')) {
207
-			$table = $schema->getTable('cards');
208
-
209
-			if ($table->hasIndex('addressbookid_uri_index')) {
210
-				$output->writeln('<info>Renaming addressbookid_uri_index index to  to the cards table, this can take some time...</info>');
211
-
212
-				foreach ($table->getIndexes() as $index) {
213
-					if ($index->getColumns() === ['addressbookid', 'uri']) {
214
-						$table->renameIndex('addressbookid_uri_index', 'cards_abiduri');
215
-					}
216
-				}
217
-
218
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
219
-				$cardsUpdated = true;
220
-			}
221
-
222
-			if (!$table->hasIndex('cards_abid')) {
223
-				$output->writeln('<info>Adding cards_abid index to the cards table, this can take some time...</info>');
224
-
225
-				foreach ($table->getIndexes() as $index) {
226
-					if ($index->getColumns() === ['addressbookid']) {
227
-						$table->dropIndex($index->getName());
228
-					}
229
-				}
230
-
231
-				$table->addIndex(['addressbookid'], 'cards_abid');
232
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
233
-				$cardsUpdated = true;
234
-			}
235
-
236
-			if (!$table->hasIndex('cards_abiduri')) {
237
-				$output->writeln('<info>Adding cards_abiduri index to the cards table, this can take some time...</info>');
238
-
239
-				foreach ($table->getIndexes() as $index) {
240
-					if ($index->getColumns() === ['addressbookid', 'uri']) {
241
-						$table->dropIndex($index->getName());
242
-					}
243
-				}
244
-
245
-				$table->addIndex(['addressbookid', 'uri'], 'cards_abiduri');
246
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
247
-				$cardsUpdated = true;
248
-			}
249
-
250
-			if ($cardsUpdated) {
251
-				$updated = true;
252
-				$output->writeln('<info>cards table updated successfully.</info>');
253
-			}
254
-		}
255
-
256
-		$output->writeln('<info>Check indices of the cards_properties table.</info>');
257
-		if ($schema->hasTable('cards_properties')) {
258
-			$table = $schema->getTable('cards_properties');
259
-			if (!$table->hasIndex('cards_prop_abid')) {
260
-				$output->writeln('<info>Adding cards_prop_abid index to the cards_properties table, this can take some time...</info>');
261
-
262
-				foreach ($table->getIndexes() as $index) {
263
-					if ($index->getColumns() === ['addressbookid']) {
264
-						$table->dropIndex($index->getName());
265
-					}
266
-				}
267
-
268
-				$table->addIndex(['addressbookid'], 'cards_prop_abid');
269
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
270
-				$updated = true;
271
-				$output->writeln('<info>cards_properties table updated successfully.</info>');
272
-			}
273
-		}
274
-
275
-		$output->writeln('<info>Check indices of the calendarobjects_props table.</info>');
276
-		if ($schema->hasTable('calendarobjects_props')) {
277
-			$table = $schema->getTable('calendarobjects_props');
278
-			if (!$table->hasIndex('calendarobject_calid_index')) {
279
-				$output->writeln('<info>Adding calendarobject_calid_index index to the calendarobjects_props table, this can take some time...</info>');
280
-
281
-				$table->addIndex(['calendarid', 'calendartype'], 'calendarobject_calid_index');
282
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
283
-				$updated = true;
284
-				$output->writeln('<info>calendarobjects_props table updated successfully.</info>');
285
-			}
286
-		}
287
-
288
-		$output->writeln('<info>Check indices of the schedulingobjects table.</info>');
289
-		if ($schema->hasTable('schedulingobjects')) {
290
-			$table = $schema->getTable('schedulingobjects');
291
-			if (!$table->hasIndex('schedulobj_principuri_index')) {
292
-				$output->writeln('<info>Adding schedulobj_principuri_index index to the schedulingobjects table, this can take some time...</info>');
293
-
294
-				$table->addIndex(['principaluri'], 'schedulobj_principuri_index');
295
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
296
-				$updated = true;
297
-				$output->writeln('<info>schedulingobjects table updated successfully.</info>');
298
-			}
299
-		}
300
-
301
-		$output->writeln('<info>Check indices of the oc_properties table.</info>');
302
-		if ($schema->hasTable('properties')) {
303
-			$table = $schema->getTable('properties');
304
-			if (!$table->hasIndex('properties_path_index')) {
305
-				$output->writeln('<info>Adding properties_path_index index to the oc_properties table, this can take some time...</info>');
306
-
307
-				$table->addIndex(['userid', 'propertypath'], 'properties_path_index');
308
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
309
-				$updated = true;
310
-				$output->writeln('<info>oc_properties table updated successfully.</info>');
311
-			}
312
-		}
313
-
314
-		if (!$updated) {
315
-			$output->writeln('<info>Done.</info>');
316
-		}
317
-	}
55
+    /** @var Connection */
56
+    private $connection;
57
+
58
+    /** @var EventDispatcherInterface */
59
+    private $dispatcher;
60
+
61
+    public function __construct(Connection $connection, EventDispatcherInterface $dispatcher) {
62
+        parent::__construct();
63
+
64
+        $this->connection = $connection;
65
+        $this->dispatcher = $dispatcher;
66
+    }
67
+
68
+    protected function configure() {
69
+        $this
70
+            ->setName('db:add-missing-indices')
71
+            ->setDescription('Add missing indices to the database tables');
72
+    }
73
+
74
+    protected function execute(InputInterface $input, OutputInterface $output): int {
75
+        $this->addCoreIndexes($output);
76
+
77
+        // Dispatch event so apps can also update indexes if needed
78
+        $event = new GenericEvent($output);
79
+        $this->dispatcher->dispatch(IDBConnection::ADD_MISSING_INDEXES_EVENT, $event);
80
+        return 0;
81
+    }
82
+
83
+    /**
84
+     * add missing indices to the share table
85
+     *
86
+     * @param OutputInterface $output
87
+     * @throws \Doctrine\DBAL\Schema\SchemaException
88
+     */
89
+    private function addCoreIndexes(OutputInterface $output) {
90
+        $output->writeln('<info>Check indices of the share table.</info>');
91
+
92
+        $schema = new SchemaWrapper($this->connection);
93
+        $updated = false;
94
+
95
+        if ($schema->hasTable('share')) {
96
+            $table = $schema->getTable('share');
97
+            if (!$table->hasIndex('share_with_index')) {
98
+                $output->writeln('<info>Adding additional share_with index to the share table, this can take some time...</info>');
99
+                $table->addIndex(['share_with'], 'share_with_index');
100
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
101
+                $updated = true;
102
+                $output->writeln('<info>Share table updated successfully.</info>');
103
+            }
104
+
105
+            if (!$table->hasIndex('parent_index')) {
106
+                $output->writeln('<info>Adding additional parent index to the share table, this can take some time...</info>');
107
+                $table->addIndex(['parent'], 'parent_index');
108
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
109
+                $updated = true;
110
+                $output->writeln('<info>Share table updated successfully.</info>');
111
+            }
112
+
113
+            if (!$table->hasIndex('owner_index')) {
114
+                $output->writeln('<info>Adding additional owner index to the share table, this can take some time...</info>');
115
+                $table->addIndex(['uid_owner'], 'owner_index');
116
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
117
+                $updated = true;
118
+                $output->writeln('<info>Share table updated successfully.</info>');
119
+            }
120
+
121
+            if (!$table->hasIndex('initiator_index')) {
122
+                $output->writeln('<info>Adding additional initiator index to the share table, this can take some time...</info>');
123
+                $table->addIndex(['uid_initiator'], 'initiator_index');
124
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
125
+                $updated = true;
126
+                $output->writeln('<info>Share table updated successfully.</info>');
127
+            }
128
+        }
129
+
130
+        $output->writeln('<info>Check indices of the filecache table.</info>');
131
+        if ($schema->hasTable('filecache')) {
132
+            $table = $schema->getTable('filecache');
133
+            if (!$table->hasIndex('fs_mtime')) {
134
+                $output->writeln('<info>Adding additional mtime index to the filecache table, this can take some time...</info>');
135
+                $table->addIndex(['mtime'], 'fs_mtime');
136
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
137
+                $updated = true;
138
+                $output->writeln('<info>Filecache table updated successfully.</info>');
139
+            }
140
+            if (!$table->hasIndex('fs_size')) {
141
+                $output->writeln('<info>Adding additional size index to the filecache table, this can take some time...</info>');
142
+                $table->addIndex(['size'], 'fs_size');
143
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
144
+                $updated = true;
145
+                $output->writeln('<info>Filecache table updated successfully.</info>');
146
+            }
147
+        }
148
+
149
+        $output->writeln('<info>Check indices of the twofactor_providers table.</info>');
150
+        if ($schema->hasTable('twofactor_providers')) {
151
+            $table = $schema->getTable('twofactor_providers');
152
+            if (!$table->hasIndex('twofactor_providers_uid')) {
153
+                $output->writeln('<info>Adding additional twofactor_providers_uid index to the twofactor_providers table, this can take some time...</info>');
154
+                $table->addIndex(['uid'], 'twofactor_providers_uid');
155
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
156
+                $updated = true;
157
+                $output->writeln('<info>Twofactor_providers table updated successfully.</info>');
158
+            }
159
+        }
160
+
161
+        $output->writeln('<info>Check indices of the login_flow_v2 table.</info>');
162
+        if ($schema->hasTable('login_flow_v2')) {
163
+            $table = $schema->getTable('login_flow_v2');
164
+            if (!$table->hasIndex('poll_token')) {
165
+                $output->writeln('<info>Adding additional indeces to the login_flow_v2 table, this can take some time...</info>');
166
+
167
+                foreach ($table->getIndexes() as $index) {
168
+                    $columns = $index->getColumns();
169
+                    if ($columns === ['poll_token'] ||
170
+                        $columns === ['login_token'] ||
171
+                        $columns === ['timestamp']) {
172
+                        $table->dropIndex($index->getName());
173
+                    }
174
+                }
175
+
176
+                $table->addUniqueIndex(['poll_token'], 'poll_token');
177
+                $table->addUniqueIndex(['login_token'], 'login_token');
178
+                $table->addIndex(['timestamp'], 'timestamp');
179
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
180
+                $updated = true;
181
+                $output->writeln('<info>login_flow_v2 table updated successfully.</info>');
182
+            }
183
+        }
184
+
185
+        $output->writeln('<info>Check indices of the whats_new table.</info>');
186
+        if ($schema->hasTable('whats_new')) {
187
+            $table = $schema->getTable('whats_new');
188
+            if (!$table->hasIndex('version')) {
189
+                $output->writeln('<info>Adding version index to the whats_new table, this can take some time...</info>');
190
+
191
+                foreach ($table->getIndexes() as $index) {
192
+                    if ($index->getColumns() === ['version']) {
193
+                        $table->dropIndex($index->getName());
194
+                    }
195
+                }
196
+
197
+                $table->addUniqueIndex(['version'], 'version');
198
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
199
+                $updated = true;
200
+                $output->writeln('<info>whats_new table updated successfully.</info>');
201
+            }
202
+        }
203
+
204
+        $output->writeln('<info>Check indices of the cards table.</info>');
205
+        $cardsUpdated = false;
206
+        if ($schema->hasTable('cards')) {
207
+            $table = $schema->getTable('cards');
208
+
209
+            if ($table->hasIndex('addressbookid_uri_index')) {
210
+                $output->writeln('<info>Renaming addressbookid_uri_index index to  to the cards table, this can take some time...</info>');
211
+
212
+                foreach ($table->getIndexes() as $index) {
213
+                    if ($index->getColumns() === ['addressbookid', 'uri']) {
214
+                        $table->renameIndex('addressbookid_uri_index', 'cards_abiduri');
215
+                    }
216
+                }
217
+
218
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
219
+                $cardsUpdated = true;
220
+            }
221
+
222
+            if (!$table->hasIndex('cards_abid')) {
223
+                $output->writeln('<info>Adding cards_abid index to the cards table, this can take some time...</info>');
224
+
225
+                foreach ($table->getIndexes() as $index) {
226
+                    if ($index->getColumns() === ['addressbookid']) {
227
+                        $table->dropIndex($index->getName());
228
+                    }
229
+                }
230
+
231
+                $table->addIndex(['addressbookid'], 'cards_abid');
232
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
233
+                $cardsUpdated = true;
234
+            }
235
+
236
+            if (!$table->hasIndex('cards_abiduri')) {
237
+                $output->writeln('<info>Adding cards_abiduri index to the cards table, this can take some time...</info>');
238
+
239
+                foreach ($table->getIndexes() as $index) {
240
+                    if ($index->getColumns() === ['addressbookid', 'uri']) {
241
+                        $table->dropIndex($index->getName());
242
+                    }
243
+                }
244
+
245
+                $table->addIndex(['addressbookid', 'uri'], 'cards_abiduri');
246
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
247
+                $cardsUpdated = true;
248
+            }
249
+
250
+            if ($cardsUpdated) {
251
+                $updated = true;
252
+                $output->writeln('<info>cards table updated successfully.</info>');
253
+            }
254
+        }
255
+
256
+        $output->writeln('<info>Check indices of the cards_properties table.</info>');
257
+        if ($schema->hasTable('cards_properties')) {
258
+            $table = $schema->getTable('cards_properties');
259
+            if (!$table->hasIndex('cards_prop_abid')) {
260
+                $output->writeln('<info>Adding cards_prop_abid index to the cards_properties table, this can take some time...</info>');
261
+
262
+                foreach ($table->getIndexes() as $index) {
263
+                    if ($index->getColumns() === ['addressbookid']) {
264
+                        $table->dropIndex($index->getName());
265
+                    }
266
+                }
267
+
268
+                $table->addIndex(['addressbookid'], 'cards_prop_abid');
269
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
270
+                $updated = true;
271
+                $output->writeln('<info>cards_properties table updated successfully.</info>');
272
+            }
273
+        }
274
+
275
+        $output->writeln('<info>Check indices of the calendarobjects_props table.</info>');
276
+        if ($schema->hasTable('calendarobjects_props')) {
277
+            $table = $schema->getTable('calendarobjects_props');
278
+            if (!$table->hasIndex('calendarobject_calid_index')) {
279
+                $output->writeln('<info>Adding calendarobject_calid_index index to the calendarobjects_props table, this can take some time...</info>');
280
+
281
+                $table->addIndex(['calendarid', 'calendartype'], 'calendarobject_calid_index');
282
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
283
+                $updated = true;
284
+                $output->writeln('<info>calendarobjects_props table updated successfully.</info>');
285
+            }
286
+        }
287
+
288
+        $output->writeln('<info>Check indices of the schedulingobjects table.</info>');
289
+        if ($schema->hasTable('schedulingobjects')) {
290
+            $table = $schema->getTable('schedulingobjects');
291
+            if (!$table->hasIndex('schedulobj_principuri_index')) {
292
+                $output->writeln('<info>Adding schedulobj_principuri_index index to the schedulingobjects table, this can take some time...</info>');
293
+
294
+                $table->addIndex(['principaluri'], 'schedulobj_principuri_index');
295
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
296
+                $updated = true;
297
+                $output->writeln('<info>schedulingobjects table updated successfully.</info>');
298
+            }
299
+        }
300
+
301
+        $output->writeln('<info>Check indices of the oc_properties table.</info>');
302
+        if ($schema->hasTable('properties')) {
303
+            $table = $schema->getTable('properties');
304
+            if (!$table->hasIndex('properties_path_index')) {
305
+                $output->writeln('<info>Adding properties_path_index index to the oc_properties table, this can take some time...</info>');
306
+
307
+                $table->addIndex(['userid', 'propertypath'], 'properties_path_index');
308
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
309
+                $updated = true;
310
+                $output->writeln('<info>oc_properties table updated successfully.</info>');
311
+            }
312
+        }
313
+
314
+        if (!$updated) {
315
+            $output->writeln('<info>Done.</info>');
316
+        }
317
+    }
318 318
 }
Please login to merge, or discard this patch.
core/Application.php 1 patch
Indentation   +212 added lines, -212 removed lines patch added patch discarded remove patch
@@ -59,216 +59,216 @@
 block discarded – undo
59 59
  * @package OC\Core
60 60
  */
61 61
 class Application extends App {
62
-	public function __construct() {
63
-		parent::__construct('core');
64
-
65
-		$container = $this->getContainer();
66
-
67
-		$container->registerService('defaultMailAddress', function () {
68
-			return Util::getDefaultEmailAddress('lostpassword-noreply');
69
-		});
70
-
71
-		$server = $container->getServer();
72
-		/** @var IEventDispatcher $eventDispatcher */
73
-		$eventDispatcher = $server->query(IEventDispatcher::class);
74
-
75
-		$notificationManager = $server->getNotificationManager();
76
-		$notificationManager->registerNotifierService(CoreNotifier::class);
77
-		$notificationManager->registerNotifierService(AuthenticationNotifier::class);
78
-
79
-		$oldEventDispatcher = $server->getEventDispatcher();
80
-
81
-		$oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_INDEXES_EVENT,
82
-			function (GenericEvent $event) use ($container) {
83
-				/** @var MissingIndexInformation $subject */
84
-				$subject = $event->getSubject();
85
-
86
-				$schema = new SchemaWrapper($container->query(Connection::class));
87
-
88
-				if ($schema->hasTable('share')) {
89
-					$table = $schema->getTable('share');
90
-
91
-					if (!$table->hasIndex('share_with_index')) {
92
-						$subject->addHintForMissingSubject($table->getName(), 'share_with_index');
93
-					}
94
-					if (!$table->hasIndex('parent_index')) {
95
-						$subject->addHintForMissingSubject($table->getName(), 'parent_index');
96
-					}
97
-					if (!$table->hasIndex('owner_index')) {
98
-						$subject->addHintForMissingSubject($table->getName(), 'owner_index');
99
-					}
100
-					if (!$table->hasIndex('initiator_index')) {
101
-						$subject->addHintForMissingSubject($table->getName(), 'initiator_index');
102
-					}
103
-				}
104
-
105
-				if ($schema->hasTable('filecache')) {
106
-					$table = $schema->getTable('filecache');
107
-
108
-					if (!$table->hasIndex('fs_mtime')) {
109
-						$subject->addHintForMissingSubject($table->getName(), 'fs_mtime');
110
-					}
111
-
112
-					if (!$table->hasIndex('fs_size')) {
113
-						$subject->addHintForMissingSubject($table->getName(), 'fs_size');
114
-					}
115
-				}
116
-
117
-				if ($schema->hasTable('twofactor_providers')) {
118
-					$table = $schema->getTable('twofactor_providers');
119
-
120
-					if (!$table->hasIndex('twofactor_providers_uid')) {
121
-						$subject->addHintForMissingSubject($table->getName(), 'twofactor_providers_uid');
122
-					}
123
-				}
124
-
125
-				if ($schema->hasTable('login_flow_v2')) {
126
-					$table = $schema->getTable('login_flow_v2');
127
-
128
-					if (!$table->hasIndex('poll_token')) {
129
-						$subject->addHintForMissingSubject($table->getName(), 'poll_token');
130
-					}
131
-					if (!$table->hasIndex('login_token')) {
132
-						$subject->addHintForMissingSubject($table->getName(), 'login_token');
133
-					}
134
-					if (!$table->hasIndex('timestamp')) {
135
-						$subject->addHintForMissingSubject($table->getName(), 'timestamp');
136
-					}
137
-				}
138
-
139
-				if ($schema->hasTable('whats_new')) {
140
-					$table = $schema->getTable('whats_new');
141
-
142
-					if (!$table->hasIndex('version')) {
143
-						$subject->addHintForMissingSubject($table->getName(), 'version');
144
-					}
145
-				}
146
-
147
-				if ($schema->hasTable('cards')) {
148
-					$table = $schema->getTable('cards');
149
-
150
-					if (!$table->hasIndex('cards_abid')) {
151
-						$subject->addHintForMissingSubject($table->getName(), 'cards_abid');
152
-					}
153
-
154
-					if (!$table->hasIndex('cards_abiduri')) {
155
-						$subject->addHintForMissingSubject($table->getName(), 'cards_abiduri');
156
-					}
157
-				}
158
-
159
-				if ($schema->hasTable('cards_properties')) {
160
-					$table = $schema->getTable('cards_properties');
161
-
162
-					if (!$table->hasIndex('cards_prop_abid')) {
163
-						$subject->addHintForMissingSubject($table->getName(), 'cards_prop_abid');
164
-					}
165
-				}
166
-
167
-				if ($schema->hasTable('calendarobjects_props')) {
168
-					$table = $schema->getTable('calendarobjects_props');
169
-
170
-					if (!$table->hasIndex('calendarobject_calid_index')) {
171
-						$subject->addHintForMissingSubject($table->getName(), 'calendarobject_calid_index');
172
-					}
173
-				}
174
-
175
-				if ($schema->hasTable('schedulingobjects')) {
176
-					$table = $schema->getTable('schedulingobjects');
177
-					if (!$table->hasIndex('schedulobj_principuri_index')) {
178
-						$subject->addHintForMissingSubject($table->getName(), 'schedulobj_principuri_index');
179
-					}
180
-				}
181
-
182
-				if ($schema->hasTable('properties')) {
183
-					$table = $schema->getTable('properties');
184
-					if (!$table->hasIndex('properties_path_index')) {
185
-						$subject->addHintForMissingSubject($table->getName(), 'properties_path_index');
186
-					}
187
-				}
188
-			}
189
-		);
190
-
191
-		$oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_PRIMARY_KEYS_EVENT,
192
-			function (GenericEvent $event) use ($container) {
193
-				/** @var MissingPrimaryKeyInformation $subject */
194
-				$subject = $event->getSubject();
195
-
196
-				$schema = new SchemaWrapper($container->query(Connection::class));
197
-
198
-				if ($schema->hasTable('federated_reshares')) {
199
-					$table = $schema->getTable('federated_reshares');
200
-
201
-					if (!$table->hasPrimaryKey()) {
202
-						$subject->addHintForMissingSubject($table->getName());
203
-					}
204
-				}
205
-
206
-				if ($schema->hasTable('systemtag_object_mapping')) {
207
-					$table = $schema->getTable('systemtag_object_mapping');
208
-
209
-					if (!$table->hasPrimaryKey()) {
210
-						$subject->addHintForMissingSubject($table->getName());
211
-					}
212
-				}
213
-
214
-				if ($schema->hasTable('comments_read_markers')) {
215
-					$table = $schema->getTable('comments_read_markers');
216
-
217
-					if (!$table->hasPrimaryKey()) {
218
-						$subject->addHintForMissingSubject($table->getName());
219
-					}
220
-				}
221
-
222
-				if ($schema->hasTable('collres_resources')) {
223
-					$table = $schema->getTable('collres_resources');
224
-
225
-					if (!$table->hasPrimaryKey()) {
226
-						$subject->addHintForMissingSubject($table->getName());
227
-					}
228
-				}
229
-
230
-				if ($schema->hasTable('collres_accesscache')) {
231
-					$table = $schema->getTable('collres_accesscache');
232
-
233
-					if (!$table->hasPrimaryKey()) {
234
-						$subject->addHintForMissingSubject($table->getName());
235
-					}
236
-				}
237
-
238
-				if ($schema->hasTable('filecache_extended')) {
239
-					$table = $schema->getTable('filecache_extended');
240
-
241
-					if (!$table->hasPrimaryKey()) {
242
-						$subject->addHintForMissingSubject($table->getName());
243
-					}
244
-				}
245
-			}
246
-		);
247
-
248
-		$oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_COLUMNS_EVENT,
249
-			function (GenericEvent $event) use ($container) {
250
-				/** @var MissingColumnInformation $subject */
251
-				$subject = $event->getSubject();
252
-
253
-				$schema = new SchemaWrapper($container->query(Connection::class));
254
-
255
-				if ($schema->hasTable('comments')) {
256
-					$table = $schema->getTable('comments');
257
-
258
-					if (!$table->hasColumn('reference_id')) {
259
-						$subject->addHintForMissingColumn($table->getName(), 'reference_id');
260
-					}
261
-				}
262
-			}
263
-		);
264
-
265
-		$eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeActivityListener::class);
266
-		$eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeNotificationsListener::class);
267
-		$eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeEmailListener::class);
268
-		$eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeActivityListener::class);
269
-		$eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeNotificationsListener::class);
270
-		$eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeEmailListener::class);
271
-		$eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedStoreCleanupListener::class);
272
-		$eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedTokenCleanupListener::class);
273
-	}
62
+    public function __construct() {
63
+        parent::__construct('core');
64
+
65
+        $container = $this->getContainer();
66
+
67
+        $container->registerService('defaultMailAddress', function () {
68
+            return Util::getDefaultEmailAddress('lostpassword-noreply');
69
+        });
70
+
71
+        $server = $container->getServer();
72
+        /** @var IEventDispatcher $eventDispatcher */
73
+        $eventDispatcher = $server->query(IEventDispatcher::class);
74
+
75
+        $notificationManager = $server->getNotificationManager();
76
+        $notificationManager->registerNotifierService(CoreNotifier::class);
77
+        $notificationManager->registerNotifierService(AuthenticationNotifier::class);
78
+
79
+        $oldEventDispatcher = $server->getEventDispatcher();
80
+
81
+        $oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_INDEXES_EVENT,
82
+            function (GenericEvent $event) use ($container) {
83
+                /** @var MissingIndexInformation $subject */
84
+                $subject = $event->getSubject();
85
+
86
+                $schema = new SchemaWrapper($container->query(Connection::class));
87
+
88
+                if ($schema->hasTable('share')) {
89
+                    $table = $schema->getTable('share');
90
+
91
+                    if (!$table->hasIndex('share_with_index')) {
92
+                        $subject->addHintForMissingSubject($table->getName(), 'share_with_index');
93
+                    }
94
+                    if (!$table->hasIndex('parent_index')) {
95
+                        $subject->addHintForMissingSubject($table->getName(), 'parent_index');
96
+                    }
97
+                    if (!$table->hasIndex('owner_index')) {
98
+                        $subject->addHintForMissingSubject($table->getName(), 'owner_index');
99
+                    }
100
+                    if (!$table->hasIndex('initiator_index')) {
101
+                        $subject->addHintForMissingSubject($table->getName(), 'initiator_index');
102
+                    }
103
+                }
104
+
105
+                if ($schema->hasTable('filecache')) {
106
+                    $table = $schema->getTable('filecache');
107
+
108
+                    if (!$table->hasIndex('fs_mtime')) {
109
+                        $subject->addHintForMissingSubject($table->getName(), 'fs_mtime');
110
+                    }
111
+
112
+                    if (!$table->hasIndex('fs_size')) {
113
+                        $subject->addHintForMissingSubject($table->getName(), 'fs_size');
114
+                    }
115
+                }
116
+
117
+                if ($schema->hasTable('twofactor_providers')) {
118
+                    $table = $schema->getTable('twofactor_providers');
119
+
120
+                    if (!$table->hasIndex('twofactor_providers_uid')) {
121
+                        $subject->addHintForMissingSubject($table->getName(), 'twofactor_providers_uid');
122
+                    }
123
+                }
124
+
125
+                if ($schema->hasTable('login_flow_v2')) {
126
+                    $table = $schema->getTable('login_flow_v2');
127
+
128
+                    if (!$table->hasIndex('poll_token')) {
129
+                        $subject->addHintForMissingSubject($table->getName(), 'poll_token');
130
+                    }
131
+                    if (!$table->hasIndex('login_token')) {
132
+                        $subject->addHintForMissingSubject($table->getName(), 'login_token');
133
+                    }
134
+                    if (!$table->hasIndex('timestamp')) {
135
+                        $subject->addHintForMissingSubject($table->getName(), 'timestamp');
136
+                    }
137
+                }
138
+
139
+                if ($schema->hasTable('whats_new')) {
140
+                    $table = $schema->getTable('whats_new');
141
+
142
+                    if (!$table->hasIndex('version')) {
143
+                        $subject->addHintForMissingSubject($table->getName(), 'version');
144
+                    }
145
+                }
146
+
147
+                if ($schema->hasTable('cards')) {
148
+                    $table = $schema->getTable('cards');
149
+
150
+                    if (!$table->hasIndex('cards_abid')) {
151
+                        $subject->addHintForMissingSubject($table->getName(), 'cards_abid');
152
+                    }
153
+
154
+                    if (!$table->hasIndex('cards_abiduri')) {
155
+                        $subject->addHintForMissingSubject($table->getName(), 'cards_abiduri');
156
+                    }
157
+                }
158
+
159
+                if ($schema->hasTable('cards_properties')) {
160
+                    $table = $schema->getTable('cards_properties');
161
+
162
+                    if (!$table->hasIndex('cards_prop_abid')) {
163
+                        $subject->addHintForMissingSubject($table->getName(), 'cards_prop_abid');
164
+                    }
165
+                }
166
+
167
+                if ($schema->hasTable('calendarobjects_props')) {
168
+                    $table = $schema->getTable('calendarobjects_props');
169
+
170
+                    if (!$table->hasIndex('calendarobject_calid_index')) {
171
+                        $subject->addHintForMissingSubject($table->getName(), 'calendarobject_calid_index');
172
+                    }
173
+                }
174
+
175
+                if ($schema->hasTable('schedulingobjects')) {
176
+                    $table = $schema->getTable('schedulingobjects');
177
+                    if (!$table->hasIndex('schedulobj_principuri_index')) {
178
+                        $subject->addHintForMissingSubject($table->getName(), 'schedulobj_principuri_index');
179
+                    }
180
+                }
181
+
182
+                if ($schema->hasTable('properties')) {
183
+                    $table = $schema->getTable('properties');
184
+                    if (!$table->hasIndex('properties_path_index')) {
185
+                        $subject->addHintForMissingSubject($table->getName(), 'properties_path_index');
186
+                    }
187
+                }
188
+            }
189
+        );
190
+
191
+        $oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_PRIMARY_KEYS_EVENT,
192
+            function (GenericEvent $event) use ($container) {
193
+                /** @var MissingPrimaryKeyInformation $subject */
194
+                $subject = $event->getSubject();
195
+
196
+                $schema = new SchemaWrapper($container->query(Connection::class));
197
+
198
+                if ($schema->hasTable('federated_reshares')) {
199
+                    $table = $schema->getTable('federated_reshares');
200
+
201
+                    if (!$table->hasPrimaryKey()) {
202
+                        $subject->addHintForMissingSubject($table->getName());
203
+                    }
204
+                }
205
+
206
+                if ($schema->hasTable('systemtag_object_mapping')) {
207
+                    $table = $schema->getTable('systemtag_object_mapping');
208
+
209
+                    if (!$table->hasPrimaryKey()) {
210
+                        $subject->addHintForMissingSubject($table->getName());
211
+                    }
212
+                }
213
+
214
+                if ($schema->hasTable('comments_read_markers')) {
215
+                    $table = $schema->getTable('comments_read_markers');
216
+
217
+                    if (!$table->hasPrimaryKey()) {
218
+                        $subject->addHintForMissingSubject($table->getName());
219
+                    }
220
+                }
221
+
222
+                if ($schema->hasTable('collres_resources')) {
223
+                    $table = $schema->getTable('collres_resources');
224
+
225
+                    if (!$table->hasPrimaryKey()) {
226
+                        $subject->addHintForMissingSubject($table->getName());
227
+                    }
228
+                }
229
+
230
+                if ($schema->hasTable('collres_accesscache')) {
231
+                    $table = $schema->getTable('collres_accesscache');
232
+
233
+                    if (!$table->hasPrimaryKey()) {
234
+                        $subject->addHintForMissingSubject($table->getName());
235
+                    }
236
+                }
237
+
238
+                if ($schema->hasTable('filecache_extended')) {
239
+                    $table = $schema->getTable('filecache_extended');
240
+
241
+                    if (!$table->hasPrimaryKey()) {
242
+                        $subject->addHintForMissingSubject($table->getName());
243
+                    }
244
+                }
245
+            }
246
+        );
247
+
248
+        $oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_COLUMNS_EVENT,
249
+            function (GenericEvent $event) use ($container) {
250
+                /** @var MissingColumnInformation $subject */
251
+                $subject = $event->getSubject();
252
+
253
+                $schema = new SchemaWrapper($container->query(Connection::class));
254
+
255
+                if ($schema->hasTable('comments')) {
256
+                    $table = $schema->getTable('comments');
257
+
258
+                    if (!$table->hasColumn('reference_id')) {
259
+                        $subject->addHintForMissingColumn($table->getName(), 'reference_id');
260
+                    }
261
+                }
262
+            }
263
+        );
264
+
265
+        $eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeActivityListener::class);
266
+        $eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeNotificationsListener::class);
267
+        $eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeEmailListener::class);
268
+        $eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeActivityListener::class);
269
+        $eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeNotificationsListener::class);
270
+        $eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeEmailListener::class);
271
+        $eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedStoreCleanupListener::class);
272
+        $eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedTokenCleanupListener::class);
273
+    }
274 274
 }
Please login to merge, or discard this patch.
core/Migrations/Version13000Date20170718121200.php 1 patch
Indentation   +942 added lines, -942 removed lines patch added patch discarded remove patch
@@ -38,850 +38,850 @@  discard block
 block discarded – undo
38 38
 
39 39
 class Version13000Date20170718121200 extends SimpleMigrationStep {
40 40
 
41
-	/** @var IDBConnection */
42
-	private $connection;
41
+    /** @var IDBConnection */
42
+    private $connection;
43 43
 
44
-	public function __construct(IDBConnection $connection) {
45
-		$this->connection = $connection;
46
-	}
44
+    public function __construct(IDBConnection $connection) {
45
+        $this->connection = $connection;
46
+    }
47 47
 
48
-	public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
49
-		/** @var ISchemaWrapper $schema */
50
-		$schema = $schemaClosure();
48
+    public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
49
+        /** @var ISchemaWrapper $schema */
50
+        $schema = $schemaClosure();
51 51
 
52
-		if (!$schema->hasTable('properties')) {
53
-			return;
54
-		}
55
-		// in case we have a properties table from oc we drop it since we will only migrate
56
-		// the dav_properties values in the postSchemaChange step
57
-		$table = $schema->getTable('properties');
58
-		if ($table->hasColumn('fileid')) {
59
-			$qb = $this->connection->getQueryBuilder();
60
-			$qb->delete('properties');
61
-			$qb->execute();
62
-		}
63
-	}
52
+        if (!$schema->hasTable('properties')) {
53
+            return;
54
+        }
55
+        // in case we have a properties table from oc we drop it since we will only migrate
56
+        // the dav_properties values in the postSchemaChange step
57
+        $table = $schema->getTable('properties');
58
+        if ($table->hasColumn('fileid')) {
59
+            $qb = $this->connection->getQueryBuilder();
60
+            $qb->delete('properties');
61
+            $qb->execute();
62
+        }
63
+    }
64 64
 
65 65
 
66
-	/**
67
-	 * @param IOutput $output
68
-	 * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
69
-	 * @param array $options
70
-	 * @return null|ISchemaWrapper
71
-	 * @since 13.0.0
72
-	 */
73
-	public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
74
-		/** @var ISchemaWrapper $schema */
75
-		$schema = $schemaClosure();
66
+    /**
67
+     * @param IOutput $output
68
+     * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
69
+     * @param array $options
70
+     * @return null|ISchemaWrapper
71
+     * @since 13.0.0
72
+     */
73
+    public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
74
+        /** @var ISchemaWrapper $schema */
75
+        $schema = $schemaClosure();
76 76
 
77
-		if (!$schema->hasTable('appconfig')) {
78
-			$table = $schema->createTable('appconfig');
79
-			$table->addColumn('appid', 'string', [
80
-				'notnull' => true,
81
-				'length' => 32,
82
-				'default' => '',
83
-			]);
84
-			$table->addColumn('configkey', 'string', [
85
-				'notnull' => true,
86
-				'length' => 64,
87
-				'default' => '',
88
-			]);
89
-			$table->addColumn('configvalue', 'text', [
90
-				'notnull' => false,
91
-			]);
92
-			$table->setPrimaryKey(['appid', 'configkey']);
93
-			$table->addIndex(['configkey'], 'appconfig_config_key_index');
94
-			$table->addIndex(['appid'], 'appconfig_appid_key');
95
-		}
77
+        if (!$schema->hasTable('appconfig')) {
78
+            $table = $schema->createTable('appconfig');
79
+            $table->addColumn('appid', 'string', [
80
+                'notnull' => true,
81
+                'length' => 32,
82
+                'default' => '',
83
+            ]);
84
+            $table->addColumn('configkey', 'string', [
85
+                'notnull' => true,
86
+                'length' => 64,
87
+                'default' => '',
88
+            ]);
89
+            $table->addColumn('configvalue', 'text', [
90
+                'notnull' => false,
91
+            ]);
92
+            $table->setPrimaryKey(['appid', 'configkey']);
93
+            $table->addIndex(['configkey'], 'appconfig_config_key_index');
94
+            $table->addIndex(['appid'], 'appconfig_appid_key');
95
+        }
96 96
 
97
-		if (!$schema->hasTable('storages')) {
98
-			$table = $schema->createTable('storages');
99
-			$table->addColumn('id', 'string', [
100
-				'notnull' => false,
101
-				'length' => 64,
102
-			]);
103
-			$table->addColumn('numeric_id', Types::BIGINT, [
104
-				'autoincrement' => true,
105
-				'notnull' => true,
106
-				'length' => 20,
107
-			]);
108
-			$table->addColumn('available', 'integer', [
109
-				'notnull' => true,
110
-				'default' => 1,
111
-			]);
112
-			$table->addColumn('last_checked', 'integer', [
113
-				'notnull' => false,
114
-			]);
115
-			$table->setPrimaryKey(['numeric_id']);
116
-			$table->addUniqueIndex(['id'], 'storages_id_index');
117
-		}
97
+        if (!$schema->hasTable('storages')) {
98
+            $table = $schema->createTable('storages');
99
+            $table->addColumn('id', 'string', [
100
+                'notnull' => false,
101
+                'length' => 64,
102
+            ]);
103
+            $table->addColumn('numeric_id', Types::BIGINT, [
104
+                'autoincrement' => true,
105
+                'notnull' => true,
106
+                'length' => 20,
107
+            ]);
108
+            $table->addColumn('available', 'integer', [
109
+                'notnull' => true,
110
+                'default' => 1,
111
+            ]);
112
+            $table->addColumn('last_checked', 'integer', [
113
+                'notnull' => false,
114
+            ]);
115
+            $table->setPrimaryKey(['numeric_id']);
116
+            $table->addUniqueIndex(['id'], 'storages_id_index');
117
+        }
118 118
 
119
-		if (!$schema->hasTable('mounts')) {
120
-			$table = $schema->createTable('mounts');
121
-			$table->addColumn('id', 'integer', [
122
-				'autoincrement' => true,
123
-				'notnull' => true,
124
-				'length' => 4,
125
-			]);
126
-			$table->addColumn('storage_id', Types::BIGINT, [
127
-				'notnull' => true,
128
-				'length' => 20,
129
-			]);
130
-			$table->addColumn('root_id', Types::BIGINT, [
131
-				'notnull' => true,
132
-				'length' => 20,
133
-			]);
134
-			$table->addColumn('user_id', 'string', [
135
-				'notnull' => true,
136
-				'length' => 64,
137
-			]);
138
-			$table->addColumn('mount_point', 'string', [
139
-				'notnull' => true,
140
-				'length' => 4000,
141
-			]);
142
-			$table->addColumn('mount_id', Types::BIGINT, [
143
-				'notnull' => false,
144
-				'length' => 20,
145
-			]);
146
-			$table->setPrimaryKey(['id']);
147
-			$table->addIndex(['user_id'], 'mounts_user_index');
148
-			$table->addIndex(['storage_id'], 'mounts_storage_index');
149
-			$table->addIndex(['root_id'], 'mounts_root_index');
150
-			$table->addIndex(['mount_id'], 'mounts_mount_id_index');
151
-			$table->addUniqueIndex(['user_id', 'root_id'], 'mounts_user_root_index');
152
-		} else {
153
-			$table = $schema->getTable('mounts');
154
-			$table->addColumn('mount_id', Types::BIGINT, [
155
-				'notnull' => false,
156
-				'length' => 20,
157
-			]);
158
-			if (!$table->hasIndex('mounts_mount_id_index')) {
159
-				$table->addIndex(['mount_id'], 'mounts_mount_id_index');
160
-			}
161
-		}
119
+        if (!$schema->hasTable('mounts')) {
120
+            $table = $schema->createTable('mounts');
121
+            $table->addColumn('id', 'integer', [
122
+                'autoincrement' => true,
123
+                'notnull' => true,
124
+                'length' => 4,
125
+            ]);
126
+            $table->addColumn('storage_id', Types::BIGINT, [
127
+                'notnull' => true,
128
+                'length' => 20,
129
+            ]);
130
+            $table->addColumn('root_id', Types::BIGINT, [
131
+                'notnull' => true,
132
+                'length' => 20,
133
+            ]);
134
+            $table->addColumn('user_id', 'string', [
135
+                'notnull' => true,
136
+                'length' => 64,
137
+            ]);
138
+            $table->addColumn('mount_point', 'string', [
139
+                'notnull' => true,
140
+                'length' => 4000,
141
+            ]);
142
+            $table->addColumn('mount_id', Types::BIGINT, [
143
+                'notnull' => false,
144
+                'length' => 20,
145
+            ]);
146
+            $table->setPrimaryKey(['id']);
147
+            $table->addIndex(['user_id'], 'mounts_user_index');
148
+            $table->addIndex(['storage_id'], 'mounts_storage_index');
149
+            $table->addIndex(['root_id'], 'mounts_root_index');
150
+            $table->addIndex(['mount_id'], 'mounts_mount_id_index');
151
+            $table->addUniqueIndex(['user_id', 'root_id'], 'mounts_user_root_index');
152
+        } else {
153
+            $table = $schema->getTable('mounts');
154
+            $table->addColumn('mount_id', Types::BIGINT, [
155
+                'notnull' => false,
156
+                'length' => 20,
157
+            ]);
158
+            if (!$table->hasIndex('mounts_mount_id_index')) {
159
+                $table->addIndex(['mount_id'], 'mounts_mount_id_index');
160
+            }
161
+        }
162 162
 
163
-		if (!$schema->hasTable('mimetypes')) {
164
-			$table = $schema->createTable('mimetypes');
165
-			$table->addColumn('id', Types::BIGINT, [
166
-				'autoincrement' => true,
167
-				'notnull' => true,
168
-				'length' => 20,
169
-			]);
170
-			$table->addColumn('mimetype', 'string', [
171
-				'notnull' => true,
172
-				'length' => 255,
173
-				'default' => '',
174
-			]);
175
-			$table->setPrimaryKey(['id']);
176
-			$table->addUniqueIndex(['mimetype'], 'mimetype_id_index');
177
-		}
163
+        if (!$schema->hasTable('mimetypes')) {
164
+            $table = $schema->createTable('mimetypes');
165
+            $table->addColumn('id', Types::BIGINT, [
166
+                'autoincrement' => true,
167
+                'notnull' => true,
168
+                'length' => 20,
169
+            ]);
170
+            $table->addColumn('mimetype', 'string', [
171
+                'notnull' => true,
172
+                'length' => 255,
173
+                'default' => '',
174
+            ]);
175
+            $table->setPrimaryKey(['id']);
176
+            $table->addUniqueIndex(['mimetype'], 'mimetype_id_index');
177
+        }
178 178
 
179
-		if (!$schema->hasTable('filecache')) {
180
-			$table = $schema->createTable('filecache');
181
-			$table->addColumn('fileid', Types::BIGINT, [
182
-				'autoincrement' => true,
183
-				'notnull' => true,
184
-				'length' => 20,
185
-			]);
186
-			$table->addColumn('storage', Types::BIGINT, [
187
-				'notnull' => true,
188
-				'length' => 20,
189
-				'default' => 0,
190
-			]);
191
-			$table->addColumn('path', 'string', [
192
-				'notnull' => false,
193
-				'length' => 4000,
194
-			]);
195
-			$table->addColumn('path_hash', 'string', [
196
-				'notnull' => true,
197
-				'length' => 32,
198
-				'default' => '',
199
-			]);
200
-			$table->addColumn('parent', Types::BIGINT, [
201
-				'notnull' => true,
202
-				'length' => 20,
203
-				'default' => 0,
204
-			]);
205
-			$table->addColumn('name', 'string', [
206
-				'notnull' => false,
207
-				'length' => 250,
208
-			]);
209
-			$table->addColumn('mimetype', Types::BIGINT, [
210
-				'notnull' => true,
211
-				'length' => 20,
212
-				'default' => 0,
213
-			]);
214
-			$table->addColumn('mimepart', Types::BIGINT, [
215
-				'notnull' => true,
216
-				'length' => 20,
217
-				'default' => 0,
218
-			]);
219
-			$table->addColumn('size', 'bigint', [
220
-				'notnull' => true,
221
-				'length' => 8,
222
-				'default' => 0,
223
-			]);
224
-			$table->addColumn('mtime', Types::BIGINT, [
225
-				'notnull' => true,
226
-				'length' => 20,
227
-				'default' => 0,
228
-			]);
229
-			$table->addColumn('storage_mtime', Types::BIGINT, [
230
-				'notnull' => true,
231
-				'length' => 20,
232
-				'default' => 0,
233
-			]);
234
-			$table->addColumn('encrypted', 'integer', [
235
-				'notnull' => true,
236
-				'length' => 4,
237
-				'default' => 0,
238
-			]);
239
-			$table->addColumn('unencrypted_size', 'bigint', [
240
-				'notnull' => true,
241
-				'length' => 8,
242
-				'default' => 0,
243
-			]);
244
-			$table->addColumn('etag', 'string', [
245
-				'notnull' => false,
246
-				'length' => 40,
247
-			]);
248
-			$table->addColumn('permissions', 'integer', [
249
-				'notnull' => false,
250
-				'length' => 4,
251
-				'default' => 0,
252
-			]);
253
-			$table->addColumn('checksum', 'string', [
254
-				'notnull' => false,
255
-				'length' => 255,
256
-			]);
257
-			$table->setPrimaryKey(['fileid']);
258
-			$table->addUniqueIndex(['storage', 'path_hash'], 'fs_storage_path_hash');
259
-			$table->addIndex(['parent', 'name'], 'fs_parent_name_hash');
260
-			$table->addIndex(['storage', 'mimetype'], 'fs_storage_mimetype');
261
-			$table->addIndex(['storage', 'mimepart'], 'fs_storage_mimepart');
262
-			$table->addIndex(['storage', 'size', 'fileid'], 'fs_storage_size');
263
-			$table->addIndex(['mtime'], 'fs_mtime');
264
-			$table->addIndex(['size'], 'fs_size');
265
-		}
179
+        if (!$schema->hasTable('filecache')) {
180
+            $table = $schema->createTable('filecache');
181
+            $table->addColumn('fileid', Types::BIGINT, [
182
+                'autoincrement' => true,
183
+                'notnull' => true,
184
+                'length' => 20,
185
+            ]);
186
+            $table->addColumn('storage', Types::BIGINT, [
187
+                'notnull' => true,
188
+                'length' => 20,
189
+                'default' => 0,
190
+            ]);
191
+            $table->addColumn('path', 'string', [
192
+                'notnull' => false,
193
+                'length' => 4000,
194
+            ]);
195
+            $table->addColumn('path_hash', 'string', [
196
+                'notnull' => true,
197
+                'length' => 32,
198
+                'default' => '',
199
+            ]);
200
+            $table->addColumn('parent', Types::BIGINT, [
201
+                'notnull' => true,
202
+                'length' => 20,
203
+                'default' => 0,
204
+            ]);
205
+            $table->addColumn('name', 'string', [
206
+                'notnull' => false,
207
+                'length' => 250,
208
+            ]);
209
+            $table->addColumn('mimetype', Types::BIGINT, [
210
+                'notnull' => true,
211
+                'length' => 20,
212
+                'default' => 0,
213
+            ]);
214
+            $table->addColumn('mimepart', Types::BIGINT, [
215
+                'notnull' => true,
216
+                'length' => 20,
217
+                'default' => 0,
218
+            ]);
219
+            $table->addColumn('size', 'bigint', [
220
+                'notnull' => true,
221
+                'length' => 8,
222
+                'default' => 0,
223
+            ]);
224
+            $table->addColumn('mtime', Types::BIGINT, [
225
+                'notnull' => true,
226
+                'length' => 20,
227
+                'default' => 0,
228
+            ]);
229
+            $table->addColumn('storage_mtime', Types::BIGINT, [
230
+                'notnull' => true,
231
+                'length' => 20,
232
+                'default' => 0,
233
+            ]);
234
+            $table->addColumn('encrypted', 'integer', [
235
+                'notnull' => true,
236
+                'length' => 4,
237
+                'default' => 0,
238
+            ]);
239
+            $table->addColumn('unencrypted_size', 'bigint', [
240
+                'notnull' => true,
241
+                'length' => 8,
242
+                'default' => 0,
243
+            ]);
244
+            $table->addColumn('etag', 'string', [
245
+                'notnull' => false,
246
+                'length' => 40,
247
+            ]);
248
+            $table->addColumn('permissions', 'integer', [
249
+                'notnull' => false,
250
+                'length' => 4,
251
+                'default' => 0,
252
+            ]);
253
+            $table->addColumn('checksum', 'string', [
254
+                'notnull' => false,
255
+                'length' => 255,
256
+            ]);
257
+            $table->setPrimaryKey(['fileid']);
258
+            $table->addUniqueIndex(['storage', 'path_hash'], 'fs_storage_path_hash');
259
+            $table->addIndex(['parent', 'name'], 'fs_parent_name_hash');
260
+            $table->addIndex(['storage', 'mimetype'], 'fs_storage_mimetype');
261
+            $table->addIndex(['storage', 'mimepart'], 'fs_storage_mimepart');
262
+            $table->addIndex(['storage', 'size', 'fileid'], 'fs_storage_size');
263
+            $table->addIndex(['mtime'], 'fs_mtime');
264
+            $table->addIndex(['size'], 'fs_size');
265
+        }
266 266
 
267
-		if (!$schema->hasTable('group_user')) {
268
-			$table = $schema->createTable('group_user');
269
-			$table->addColumn('gid', 'string', [
270
-				'notnull' => true,
271
-				'length' => 64,
272
-				'default' => '',
273
-			]);
274
-			$table->addColumn('uid', 'string', [
275
-				'notnull' => true,
276
-				'length' => 64,
277
-				'default' => '',
278
-			]);
279
-			$table->setPrimaryKey(['gid', 'uid']);
280
-			$table->addIndex(['uid'], 'gu_uid_index');
281
-		}
267
+        if (!$schema->hasTable('group_user')) {
268
+            $table = $schema->createTable('group_user');
269
+            $table->addColumn('gid', 'string', [
270
+                'notnull' => true,
271
+                'length' => 64,
272
+                'default' => '',
273
+            ]);
274
+            $table->addColumn('uid', 'string', [
275
+                'notnull' => true,
276
+                'length' => 64,
277
+                'default' => '',
278
+            ]);
279
+            $table->setPrimaryKey(['gid', 'uid']);
280
+            $table->addIndex(['uid'], 'gu_uid_index');
281
+        }
282 282
 
283
-		if (!$schema->hasTable('group_admin')) {
284
-			$table = $schema->createTable('group_admin');
285
-			$table->addColumn('gid', 'string', [
286
-				'notnull' => true,
287
-				'length' => 64,
288
-				'default' => '',
289
-			]);
290
-			$table->addColumn('uid', 'string', [
291
-				'notnull' => true,
292
-				'length' => 64,
293
-				'default' => '',
294
-			]);
295
-			$table->setPrimaryKey(['gid', 'uid']);
296
-			$table->addIndex(['uid'], 'group_admin_uid');
297
-		}
283
+        if (!$schema->hasTable('group_admin')) {
284
+            $table = $schema->createTable('group_admin');
285
+            $table->addColumn('gid', 'string', [
286
+                'notnull' => true,
287
+                'length' => 64,
288
+                'default' => '',
289
+            ]);
290
+            $table->addColumn('uid', 'string', [
291
+                'notnull' => true,
292
+                'length' => 64,
293
+                'default' => '',
294
+            ]);
295
+            $table->setPrimaryKey(['gid', 'uid']);
296
+            $table->addIndex(['uid'], 'group_admin_uid');
297
+        }
298 298
 
299
-		if (!$schema->hasTable('groups')) {
300
-			$table = $schema->createTable('groups');
301
-			$table->addColumn('gid', 'string', [
302
-				'notnull' => true,
303
-				'length' => 64,
304
-				'default' => '',
305
-			]);
306
-			$table->setPrimaryKey(['gid']);
307
-		}
299
+        if (!$schema->hasTable('groups')) {
300
+            $table = $schema->createTable('groups');
301
+            $table->addColumn('gid', 'string', [
302
+                'notnull' => true,
303
+                'length' => 64,
304
+                'default' => '',
305
+            ]);
306
+            $table->setPrimaryKey(['gid']);
307
+        }
308 308
 
309
-		if (!$schema->hasTable('preferences')) {
310
-			$table = $schema->createTable('preferences');
311
-			$table->addColumn('userid', 'string', [
312
-				'notnull' => true,
313
-				'length' => 64,
314
-				'default' => '',
315
-			]);
316
-			$table->addColumn('appid', 'string', [
317
-				'notnull' => true,
318
-				'length' => 32,
319
-				'default' => '',
320
-			]);
321
-			$table->addColumn('configkey', 'string', [
322
-				'notnull' => true,
323
-				'length' => 64,
324
-				'default' => '',
325
-			]);
326
-			$table->addColumn('configvalue', 'text', [
327
-				'notnull' => false,
328
-			]);
329
-			$table->setPrimaryKey(['userid', 'appid', 'configkey']);
330
-		}
309
+        if (!$schema->hasTable('preferences')) {
310
+            $table = $schema->createTable('preferences');
311
+            $table->addColumn('userid', 'string', [
312
+                'notnull' => true,
313
+                'length' => 64,
314
+                'default' => '',
315
+            ]);
316
+            $table->addColumn('appid', 'string', [
317
+                'notnull' => true,
318
+                'length' => 32,
319
+                'default' => '',
320
+            ]);
321
+            $table->addColumn('configkey', 'string', [
322
+                'notnull' => true,
323
+                'length' => 64,
324
+                'default' => '',
325
+            ]);
326
+            $table->addColumn('configvalue', 'text', [
327
+                'notnull' => false,
328
+            ]);
329
+            $table->setPrimaryKey(['userid', 'appid', 'configkey']);
330
+        }
331 331
 
332
-		if (!$schema->hasTable('properties')) {
333
-			$table = $schema->createTable('properties');
334
-			$table->addColumn('id', 'integer', [
335
-				'autoincrement' => true,
336
-				'notnull' => true,
337
-				'length' => 4,
338
-			]);
339
-			$table->addColumn('userid', 'string', [
340
-				'notnull' => true,
341
-				'length' => 64,
342
-				'default' => '',
343
-			]);
344
-			$table->addColumn('propertypath', 'string', [
345
-				'notnull' => true,
346
-				'length' => 255,
347
-				'default' => '',
348
-			]);
349
-			$table->addColumn('propertyname', 'string', [
350
-				'notnull' => true,
351
-				'length' => 255,
352
-				'default' => '',
353
-			]);
354
-			$table->addColumn('propertyvalue', 'text', [
355
-				'notnull' => true,
356
-			]);
357
-			$table->setPrimaryKey(['id']);
358
-			$table->addIndex(['userid'], 'property_index');
359
-			$table->addIndex(['userid', 'propertypath'], 'properties_path_index');
360
-		} else {
361
-			$table = $schema->getTable('properties');
362
-			if ($table->hasColumn('propertytype')) {
363
-				$table->dropColumn('propertytype');
364
-			}
365
-			if ($table->hasColumn('fileid')) {
366
-				$table->dropColumn('fileid');
367
-			}
368
-			if (!$table->hasColumn('propertypath')) {
369
-				$table->addColumn('propertypath', 'string', [
370
-					'notnull' => true,
371
-					'length' => 255,
372
-				]);
373
-			}
374
-			if (!$table->hasColumn('userid')) {
375
-				$table->addColumn('userid', 'string', [
376
-					'notnull' => false,
377
-					'length' => 64,
378
-					'default' => '',
379
-				]);
380
-			}
381
-		}
332
+        if (!$schema->hasTable('properties')) {
333
+            $table = $schema->createTable('properties');
334
+            $table->addColumn('id', 'integer', [
335
+                'autoincrement' => true,
336
+                'notnull' => true,
337
+                'length' => 4,
338
+            ]);
339
+            $table->addColumn('userid', 'string', [
340
+                'notnull' => true,
341
+                'length' => 64,
342
+                'default' => '',
343
+            ]);
344
+            $table->addColumn('propertypath', 'string', [
345
+                'notnull' => true,
346
+                'length' => 255,
347
+                'default' => '',
348
+            ]);
349
+            $table->addColumn('propertyname', 'string', [
350
+                'notnull' => true,
351
+                'length' => 255,
352
+                'default' => '',
353
+            ]);
354
+            $table->addColumn('propertyvalue', 'text', [
355
+                'notnull' => true,
356
+            ]);
357
+            $table->setPrimaryKey(['id']);
358
+            $table->addIndex(['userid'], 'property_index');
359
+            $table->addIndex(['userid', 'propertypath'], 'properties_path_index');
360
+        } else {
361
+            $table = $schema->getTable('properties');
362
+            if ($table->hasColumn('propertytype')) {
363
+                $table->dropColumn('propertytype');
364
+            }
365
+            if ($table->hasColumn('fileid')) {
366
+                $table->dropColumn('fileid');
367
+            }
368
+            if (!$table->hasColumn('propertypath')) {
369
+                $table->addColumn('propertypath', 'string', [
370
+                    'notnull' => true,
371
+                    'length' => 255,
372
+                ]);
373
+            }
374
+            if (!$table->hasColumn('userid')) {
375
+                $table->addColumn('userid', 'string', [
376
+                    'notnull' => false,
377
+                    'length' => 64,
378
+                    'default' => '',
379
+                ]);
380
+            }
381
+        }
382 382
 
383
-		if (!$schema->hasTable('share')) {
384
-			$table = $schema->createTable('share');
385
-			$table->addColumn('id', 'integer', [
386
-				'autoincrement' => true,
387
-				'notnull' => true,
388
-				'length' => 4,
389
-			]);
390
-			$table->addColumn('share_type', 'smallint', [
391
-				'notnull' => true,
392
-				'length' => 1,
393
-				'default' => 0,
394
-			]);
395
-			$table->addColumn('share_with', 'string', [
396
-				'notnull' => false,
397
-				'length' => 255,
398
-			]);
399
-			$table->addColumn('password', 'string', [
400
-				'notnull' => false,
401
-				'length' => 255,
402
-			]);
403
-			$table->addColumn('uid_owner', 'string', [
404
-				'notnull' => true,
405
-				'length' => 64,
406
-				'default' => '',
407
-			]);
408
-			$table->addColumn('uid_initiator', 'string', [
409
-				'notnull' => false,
410
-				'length' => 64,
411
-			]);
412
-			$table->addColumn('parent', 'integer', [
413
-				'notnull' => false,
414
-				'length' => 4,
415
-			]);
416
-			$table->addColumn('item_type', 'string', [
417
-				'notnull' => true,
418
-				'length' => 64,
419
-				'default' => '',
420
-			]);
421
-			$table->addColumn('item_source', 'string', [
422
-				'notnull' => false,
423
-				'length' => 255,
424
-			]);
425
-			$table->addColumn('item_target', 'string', [
426
-				'notnull' => false,
427
-				'length' => 255,
428
-			]);
429
-			$table->addColumn('file_source', 'integer', [
430
-				'notnull' => false,
431
-				'length' => 4,
432
-			]);
433
-			$table->addColumn('file_target', 'string', [
434
-				'notnull' => false,
435
-				'length' => 512,
436
-			]);
437
-			$table->addColumn('permissions', 'smallint', [
438
-				'notnull' => true,
439
-				'length' => 1,
440
-				'default' => 0,
441
-			]);
442
-			$table->addColumn('stime', 'bigint', [
443
-				'notnull' => true,
444
-				'length' => 8,
445
-				'default' => 0,
446
-			]);
447
-			$table->addColumn('accepted', 'smallint', [
448
-				'notnull' => true,
449
-				'length' => 1,
450
-				'default' => 0,
451
-			]);
452
-			$table->addColumn('expiration', 'datetime', [
453
-				'notnull' => false,
454
-			]);
455
-			$table->addColumn('token', 'string', [
456
-				'notnull' => false,
457
-				'length' => 32,
458
-			]);
459
-			$table->addColumn('mail_send', 'smallint', [
460
-				'notnull' => true,
461
-				'length' => 1,
462
-				'default' => 0,
463
-			]);
464
-			$table->addColumn('share_name', 'string', [
465
-				'notnull' => false,
466
-				'length' => 64,
467
-			]);
468
-			$table->setPrimaryKey(['id']);
469
-			$table->addIndex(['item_type', 'share_type'], 'item_share_type_index');
470
-			$table->addIndex(['file_source'], 'file_source_index');
471
-			$table->addIndex(['token'], 'token_index');
472
-			$table->addIndex(['share_with'], 'share_with_index');
473
-			$table->addIndex(['parent'], 'parent_index');
474
-			$table->addIndex(['uid_owner'], 'owner_index');
475
-			$table->addIndex(['uid_initiator'], 'initiator_index');
476
-		} else {
477
-			$table = $schema->getTable('share');
478
-			if (!$table->hasColumn('password')) {
479
-				$table->addColumn('password', 'string', [
480
-					'notnull' => false,
481
-					'length' => 255,
482
-				]);
483
-			}
484
-		}
383
+        if (!$schema->hasTable('share')) {
384
+            $table = $schema->createTable('share');
385
+            $table->addColumn('id', 'integer', [
386
+                'autoincrement' => true,
387
+                'notnull' => true,
388
+                'length' => 4,
389
+            ]);
390
+            $table->addColumn('share_type', 'smallint', [
391
+                'notnull' => true,
392
+                'length' => 1,
393
+                'default' => 0,
394
+            ]);
395
+            $table->addColumn('share_with', 'string', [
396
+                'notnull' => false,
397
+                'length' => 255,
398
+            ]);
399
+            $table->addColumn('password', 'string', [
400
+                'notnull' => false,
401
+                'length' => 255,
402
+            ]);
403
+            $table->addColumn('uid_owner', 'string', [
404
+                'notnull' => true,
405
+                'length' => 64,
406
+                'default' => '',
407
+            ]);
408
+            $table->addColumn('uid_initiator', 'string', [
409
+                'notnull' => false,
410
+                'length' => 64,
411
+            ]);
412
+            $table->addColumn('parent', 'integer', [
413
+                'notnull' => false,
414
+                'length' => 4,
415
+            ]);
416
+            $table->addColumn('item_type', 'string', [
417
+                'notnull' => true,
418
+                'length' => 64,
419
+                'default' => '',
420
+            ]);
421
+            $table->addColumn('item_source', 'string', [
422
+                'notnull' => false,
423
+                'length' => 255,
424
+            ]);
425
+            $table->addColumn('item_target', 'string', [
426
+                'notnull' => false,
427
+                'length' => 255,
428
+            ]);
429
+            $table->addColumn('file_source', 'integer', [
430
+                'notnull' => false,
431
+                'length' => 4,
432
+            ]);
433
+            $table->addColumn('file_target', 'string', [
434
+                'notnull' => false,
435
+                'length' => 512,
436
+            ]);
437
+            $table->addColumn('permissions', 'smallint', [
438
+                'notnull' => true,
439
+                'length' => 1,
440
+                'default' => 0,
441
+            ]);
442
+            $table->addColumn('stime', 'bigint', [
443
+                'notnull' => true,
444
+                'length' => 8,
445
+                'default' => 0,
446
+            ]);
447
+            $table->addColumn('accepted', 'smallint', [
448
+                'notnull' => true,
449
+                'length' => 1,
450
+                'default' => 0,
451
+            ]);
452
+            $table->addColumn('expiration', 'datetime', [
453
+                'notnull' => false,
454
+            ]);
455
+            $table->addColumn('token', 'string', [
456
+                'notnull' => false,
457
+                'length' => 32,
458
+            ]);
459
+            $table->addColumn('mail_send', 'smallint', [
460
+                'notnull' => true,
461
+                'length' => 1,
462
+                'default' => 0,
463
+            ]);
464
+            $table->addColumn('share_name', 'string', [
465
+                'notnull' => false,
466
+                'length' => 64,
467
+            ]);
468
+            $table->setPrimaryKey(['id']);
469
+            $table->addIndex(['item_type', 'share_type'], 'item_share_type_index');
470
+            $table->addIndex(['file_source'], 'file_source_index');
471
+            $table->addIndex(['token'], 'token_index');
472
+            $table->addIndex(['share_with'], 'share_with_index');
473
+            $table->addIndex(['parent'], 'parent_index');
474
+            $table->addIndex(['uid_owner'], 'owner_index');
475
+            $table->addIndex(['uid_initiator'], 'initiator_index');
476
+        } else {
477
+            $table = $schema->getTable('share');
478
+            if (!$table->hasColumn('password')) {
479
+                $table->addColumn('password', 'string', [
480
+                    'notnull' => false,
481
+                    'length' => 255,
482
+                ]);
483
+            }
484
+        }
485 485
 
486
-		if (!$schema->hasTable('jobs')) {
487
-			$table = $schema->createTable('jobs');
488
-			$table->addColumn('id', 'integer', [
489
-				'autoincrement' => true,
490
-				'notnull' => true,
491
-				'length' => 4,
492
-				'unsigned' => true,
493
-			]);
494
-			$table->addColumn('class', 'string', [
495
-				'notnull' => true,
496
-				'length' => 255,
497
-				'default' => '',
498
-			]);
499
-			$table->addColumn('argument', 'string', [
500
-				'notnull' => true,
501
-				'length' => 4000,
502
-				'default' => '',
503
-			]);
504
-			$table->addColumn('last_run', 'integer', [
505
-				'notnull' => false,
506
-				'default' => 0,
507
-			]);
508
-			$table->addColumn('last_checked', 'integer', [
509
-				'notnull' => false,
510
-				'default' => 0,
511
-			]);
512
-			$table->addColumn('reserved_at', 'integer', [
513
-				'notnull' => false,
514
-				'default' => 0,
515
-			]);
516
-			$table->addColumn('execution_duration', 'integer', [
517
-				'notnull' => true,
518
-				'default' => 0,
519
-			]);
520
-			$table->setPrimaryKey(['id']);
521
-			$table->addIndex(['class'], 'job_class_index');
522
-		}
486
+        if (!$schema->hasTable('jobs')) {
487
+            $table = $schema->createTable('jobs');
488
+            $table->addColumn('id', 'integer', [
489
+                'autoincrement' => true,
490
+                'notnull' => true,
491
+                'length' => 4,
492
+                'unsigned' => true,
493
+            ]);
494
+            $table->addColumn('class', 'string', [
495
+                'notnull' => true,
496
+                'length' => 255,
497
+                'default' => '',
498
+            ]);
499
+            $table->addColumn('argument', 'string', [
500
+                'notnull' => true,
501
+                'length' => 4000,
502
+                'default' => '',
503
+            ]);
504
+            $table->addColumn('last_run', 'integer', [
505
+                'notnull' => false,
506
+                'default' => 0,
507
+            ]);
508
+            $table->addColumn('last_checked', 'integer', [
509
+                'notnull' => false,
510
+                'default' => 0,
511
+            ]);
512
+            $table->addColumn('reserved_at', 'integer', [
513
+                'notnull' => false,
514
+                'default' => 0,
515
+            ]);
516
+            $table->addColumn('execution_duration', 'integer', [
517
+                'notnull' => true,
518
+                'default' => 0,
519
+            ]);
520
+            $table->setPrimaryKey(['id']);
521
+            $table->addIndex(['class'], 'job_class_index');
522
+        }
523 523
 
524
-		if (!$schema->hasTable('users')) {
525
-			$table = $schema->createTable('users');
526
-			$table->addColumn('uid', 'string', [
527
-				'notnull' => true,
528
-				'length' => 64,
529
-				'default' => '',
530
-			]);
531
-			$table->addColumn('displayname', 'string', [
532
-				'notnull' => false,
533
-				'length' => 64,
534
-			]);
535
-			$table->addColumn('password', 'string', [
536
-				'notnull' => true,
537
-				'length' => 255,
538
-				'default' => '',
539
-			]);
540
-			$table->setPrimaryKey(['uid']);
541
-		}
524
+        if (!$schema->hasTable('users')) {
525
+            $table = $schema->createTable('users');
526
+            $table->addColumn('uid', 'string', [
527
+                'notnull' => true,
528
+                'length' => 64,
529
+                'default' => '',
530
+            ]);
531
+            $table->addColumn('displayname', 'string', [
532
+                'notnull' => false,
533
+                'length' => 64,
534
+            ]);
535
+            $table->addColumn('password', 'string', [
536
+                'notnull' => true,
537
+                'length' => 255,
538
+                'default' => '',
539
+            ]);
540
+            $table->setPrimaryKey(['uid']);
541
+        }
542 542
 
543
-		if (!$schema->hasTable('authtoken')) {
544
-			$table = $schema->createTable('authtoken');
545
-			$table->addColumn('id', 'integer', [
546
-				'autoincrement' => true,
547
-				'notnull' => true,
548
-				'length' => 4,
549
-				'unsigned' => true,
550
-			]);
551
-			$table->addColumn('uid', 'string', [
552
-				'notnull' => true,
553
-				'length' => 64,
554
-				'default' => '',
555
-			]);
556
-			$table->addColumn('login_name', 'string', [
557
-				'notnull' => true,
558
-				'length' => 64,
559
-				'default' => '',
560
-			]);
561
-			$table->addColumn('password', 'text', [
562
-				'notnull' => false,
563
-			]);
564
-			$table->addColumn('name', 'text', [
565
-				'notnull' => true,
566
-				'default' => '',
567
-			]);
568
-			$table->addColumn('token', 'string', [
569
-				'notnull' => true,
570
-				'length' => 200,
571
-				'default' => '',
572
-			]);
573
-			$table->addColumn('type', 'smallint', [
574
-				'notnull' => false,
575
-				'length' => 2,
576
-				'default' => 0,
577
-				'unsigned' => true,
578
-			]);
579
-			$table->addColumn('remember', 'smallint', [
580
-				'notnull' => false,
581
-				'length' => 1,
582
-				'default' => 0,
583
-				'unsigned' => true,
584
-			]);
585
-			$table->addColumn('last_activity', 'integer', [
586
-				'notnull' => false,
587
-				'length' => 4,
588
-				'default' => 0,
589
-				'unsigned' => true,
590
-			]);
591
-			$table->addColumn('last_check', 'integer', [
592
-				'notnull' => false,
593
-				'length' => 4,
594
-				'default' => 0,
595
-				'unsigned' => true,
596
-			]);
597
-			$table->addColumn('scope', 'text', [
598
-				'notnull' => false,
599
-			]);
600
-			$table->setPrimaryKey(['id']);
601
-			$table->addUniqueIndex(['token'], 'authtoken_token_index');
602
-			$table->addIndex(['last_activity'], 'authtoken_last_activity_idx');
603
-		} else {
604
-			$table = $schema->getTable('authtoken');
605
-			$table->addColumn('scope', 'text', [
606
-				'notnull' => false,
607
-			]);
608
-		}
543
+        if (!$schema->hasTable('authtoken')) {
544
+            $table = $schema->createTable('authtoken');
545
+            $table->addColumn('id', 'integer', [
546
+                'autoincrement' => true,
547
+                'notnull' => true,
548
+                'length' => 4,
549
+                'unsigned' => true,
550
+            ]);
551
+            $table->addColumn('uid', 'string', [
552
+                'notnull' => true,
553
+                'length' => 64,
554
+                'default' => '',
555
+            ]);
556
+            $table->addColumn('login_name', 'string', [
557
+                'notnull' => true,
558
+                'length' => 64,
559
+                'default' => '',
560
+            ]);
561
+            $table->addColumn('password', 'text', [
562
+                'notnull' => false,
563
+            ]);
564
+            $table->addColumn('name', 'text', [
565
+                'notnull' => true,
566
+                'default' => '',
567
+            ]);
568
+            $table->addColumn('token', 'string', [
569
+                'notnull' => true,
570
+                'length' => 200,
571
+                'default' => '',
572
+            ]);
573
+            $table->addColumn('type', 'smallint', [
574
+                'notnull' => false,
575
+                'length' => 2,
576
+                'default' => 0,
577
+                'unsigned' => true,
578
+            ]);
579
+            $table->addColumn('remember', 'smallint', [
580
+                'notnull' => false,
581
+                'length' => 1,
582
+                'default' => 0,
583
+                'unsigned' => true,
584
+            ]);
585
+            $table->addColumn('last_activity', 'integer', [
586
+                'notnull' => false,
587
+                'length' => 4,
588
+                'default' => 0,
589
+                'unsigned' => true,
590
+            ]);
591
+            $table->addColumn('last_check', 'integer', [
592
+                'notnull' => false,
593
+                'length' => 4,
594
+                'default' => 0,
595
+                'unsigned' => true,
596
+            ]);
597
+            $table->addColumn('scope', 'text', [
598
+                'notnull' => false,
599
+            ]);
600
+            $table->setPrimaryKey(['id']);
601
+            $table->addUniqueIndex(['token'], 'authtoken_token_index');
602
+            $table->addIndex(['last_activity'], 'authtoken_last_activity_idx');
603
+        } else {
604
+            $table = $schema->getTable('authtoken');
605
+            $table->addColumn('scope', 'text', [
606
+                'notnull' => false,
607
+            ]);
608
+        }
609 609
 
610
-		if (!$schema->hasTable('bruteforce_attempts')) {
611
-			$table = $schema->createTable('bruteforce_attempts');
612
-			$table->addColumn('id', 'integer', [
613
-				'autoincrement' => true,
614
-				'notnull' => true,
615
-				'length' => 4,
616
-				'unsigned' => true,
617
-			]);
618
-			$table->addColumn('action', 'string', [
619
-				'notnull' => true,
620
-				'length' => 64,
621
-				'default' => '',
622
-			]);
623
-			$table->addColumn('occurred', 'integer', [
624
-				'notnull' => true,
625
-				'length' => 4,
626
-				'default' => 0,
627
-				'unsigned' => true,
628
-			]);
629
-			$table->addColumn('ip', 'string', [
630
-				'notnull' => true,
631
-				'length' => 255,
632
-				'default' => '',
633
-			]);
634
-			$table->addColumn('subnet', 'string', [
635
-				'notnull' => true,
636
-				'length' => 255,
637
-				'default' => '',
638
-			]);
639
-			$table->addColumn('metadata', 'string', [
640
-				'notnull' => true,
641
-				'length' => 255,
642
-				'default' => '',
643
-			]);
644
-			$table->setPrimaryKey(['id']);
645
-			$table->addIndex(['ip'], 'bruteforce_attempts_ip');
646
-			$table->addIndex(['subnet'], 'bruteforce_attempts_subnet');
647
-		}
610
+        if (!$schema->hasTable('bruteforce_attempts')) {
611
+            $table = $schema->createTable('bruteforce_attempts');
612
+            $table->addColumn('id', 'integer', [
613
+                'autoincrement' => true,
614
+                'notnull' => true,
615
+                'length' => 4,
616
+                'unsigned' => true,
617
+            ]);
618
+            $table->addColumn('action', 'string', [
619
+                'notnull' => true,
620
+                'length' => 64,
621
+                'default' => '',
622
+            ]);
623
+            $table->addColumn('occurred', 'integer', [
624
+                'notnull' => true,
625
+                'length' => 4,
626
+                'default' => 0,
627
+                'unsigned' => true,
628
+            ]);
629
+            $table->addColumn('ip', 'string', [
630
+                'notnull' => true,
631
+                'length' => 255,
632
+                'default' => '',
633
+            ]);
634
+            $table->addColumn('subnet', 'string', [
635
+                'notnull' => true,
636
+                'length' => 255,
637
+                'default' => '',
638
+            ]);
639
+            $table->addColumn('metadata', 'string', [
640
+                'notnull' => true,
641
+                'length' => 255,
642
+                'default' => '',
643
+            ]);
644
+            $table->setPrimaryKey(['id']);
645
+            $table->addIndex(['ip'], 'bruteforce_attempts_ip');
646
+            $table->addIndex(['subnet'], 'bruteforce_attempts_subnet');
647
+        }
648 648
 
649
-		if (!$schema->hasTable('vcategory')) {
650
-			$table = $schema->createTable('vcategory');
651
-			$table->addColumn('id', 'integer', [
652
-				'autoincrement' => true,
653
-				'notnull' => true,
654
-				'length' => 4,
655
-				'unsigned' => true,
656
-			]);
657
-			$table->addColumn('uid', 'string', [
658
-				'notnull' => true,
659
-				'length' => 64,
660
-				'default' => '',
661
-			]);
662
-			$table->addColumn('type', 'string', [
663
-				'notnull' => true,
664
-				'length' => 64,
665
-				'default' => '',
666
-			]);
667
-			$table->addColumn('category', 'string', [
668
-				'notnull' => true,
669
-				'length' => 255,
670
-				'default' => '',
671
-			]);
672
-			$table->setPrimaryKey(['id']);
673
-			$table->addIndex(['uid'], 'uid_index');
674
-			$table->addIndex(['type'], 'type_index');
675
-			$table->addIndex(['category'], 'category_index');
676
-		}
649
+        if (!$schema->hasTable('vcategory')) {
650
+            $table = $schema->createTable('vcategory');
651
+            $table->addColumn('id', 'integer', [
652
+                'autoincrement' => true,
653
+                'notnull' => true,
654
+                'length' => 4,
655
+                'unsigned' => true,
656
+            ]);
657
+            $table->addColumn('uid', 'string', [
658
+                'notnull' => true,
659
+                'length' => 64,
660
+                'default' => '',
661
+            ]);
662
+            $table->addColumn('type', 'string', [
663
+                'notnull' => true,
664
+                'length' => 64,
665
+                'default' => '',
666
+            ]);
667
+            $table->addColumn('category', 'string', [
668
+                'notnull' => true,
669
+                'length' => 255,
670
+                'default' => '',
671
+            ]);
672
+            $table->setPrimaryKey(['id']);
673
+            $table->addIndex(['uid'], 'uid_index');
674
+            $table->addIndex(['type'], 'type_index');
675
+            $table->addIndex(['category'], 'category_index');
676
+        }
677 677
 
678
-		if (!$schema->hasTable('vcategory_to_object')) {
679
-			$table = $schema->createTable('vcategory_to_object');
680
-			$table->addColumn('objid', 'integer', [
681
-				'notnull' => true,
682
-				'length' => 4,
683
-				'default' => 0,
684
-				'unsigned' => true,
685
-			]);
686
-			$table->addColumn('categoryid', 'integer', [
687
-				'notnull' => true,
688
-				'length' => 4,
689
-				'default' => 0,
690
-				'unsigned' => true,
691
-			]);
692
-			$table->addColumn('type', 'string', [
693
-				'notnull' => true,
694
-				'length' => 64,
695
-				'default' => '',
696
-			]);
697
-			$table->setPrimaryKey(['categoryid', 'objid', 'type']);
698
-			$table->addIndex(['objid', 'type'], 'vcategory_objectd_index');
699
-		}
678
+        if (!$schema->hasTable('vcategory_to_object')) {
679
+            $table = $schema->createTable('vcategory_to_object');
680
+            $table->addColumn('objid', 'integer', [
681
+                'notnull' => true,
682
+                'length' => 4,
683
+                'default' => 0,
684
+                'unsigned' => true,
685
+            ]);
686
+            $table->addColumn('categoryid', 'integer', [
687
+                'notnull' => true,
688
+                'length' => 4,
689
+                'default' => 0,
690
+                'unsigned' => true,
691
+            ]);
692
+            $table->addColumn('type', 'string', [
693
+                'notnull' => true,
694
+                'length' => 64,
695
+                'default' => '',
696
+            ]);
697
+            $table->setPrimaryKey(['categoryid', 'objid', 'type']);
698
+            $table->addIndex(['objid', 'type'], 'vcategory_objectd_index');
699
+        }
700 700
 
701
-		if (!$schema->hasTable('systemtag')) {
702
-			$table = $schema->createTable('systemtag');
703
-			$table->addColumn('id', 'integer', [
704
-				'autoincrement' => true,
705
-				'notnull' => true,
706
-				'length' => 4,
707
-				'unsigned' => true,
708
-			]);
709
-			$table->addColumn('name', 'string', [
710
-				'notnull' => true,
711
-				'length' => 64,
712
-				'default' => '',
713
-			]);
714
-			$table->addColumn('visibility', 'smallint', [
715
-				'notnull' => true,
716
-				'length' => 1,
717
-				'default' => 1,
718
-			]);
719
-			$table->addColumn('editable', 'smallint', [
720
-				'notnull' => true,
721
-				'length' => 1,
722
-				'default' => 1,
723
-			]);
724
-			$table->setPrimaryKey(['id']);
725
-			$table->addUniqueIndex(['name', 'visibility', 'editable'], 'tag_ident');
726
-		}
701
+        if (!$schema->hasTable('systemtag')) {
702
+            $table = $schema->createTable('systemtag');
703
+            $table->addColumn('id', 'integer', [
704
+                'autoincrement' => true,
705
+                'notnull' => true,
706
+                'length' => 4,
707
+                'unsigned' => true,
708
+            ]);
709
+            $table->addColumn('name', 'string', [
710
+                'notnull' => true,
711
+                'length' => 64,
712
+                'default' => '',
713
+            ]);
714
+            $table->addColumn('visibility', 'smallint', [
715
+                'notnull' => true,
716
+                'length' => 1,
717
+                'default' => 1,
718
+            ]);
719
+            $table->addColumn('editable', 'smallint', [
720
+                'notnull' => true,
721
+                'length' => 1,
722
+                'default' => 1,
723
+            ]);
724
+            $table->setPrimaryKey(['id']);
725
+            $table->addUniqueIndex(['name', 'visibility', 'editable'], 'tag_ident');
726
+        }
727 727
 
728
-		if (!$schema->hasTable('systemtag_object_mapping')) {
729
-			$table = $schema->createTable('systemtag_object_mapping');
730
-			$table->addColumn('objectid', 'string', [
731
-				'notnull' => true,
732
-				'length' => 64,
733
-				'default' => '',
734
-			]);
735
-			$table->addColumn('objecttype', 'string', [
736
-				'notnull' => true,
737
-				'length' => 64,
738
-				'default' => '',
739
-			]);
740
-			$table->addColumn('systemtagid', 'integer', [
741
-				'notnull' => true,
742
-				'length' => 4,
743
-				'default' => 0,
744
-				'unsigned' => true,
745
-			]);
746
-			$table->setPrimaryKey(['objecttype', 'objectid', 'systemtagid'], 'som_pk');
728
+        if (!$schema->hasTable('systemtag_object_mapping')) {
729
+            $table = $schema->createTable('systemtag_object_mapping');
730
+            $table->addColumn('objectid', 'string', [
731
+                'notnull' => true,
732
+                'length' => 64,
733
+                'default' => '',
734
+            ]);
735
+            $table->addColumn('objecttype', 'string', [
736
+                'notnull' => true,
737
+                'length' => 64,
738
+                'default' => '',
739
+            ]);
740
+            $table->addColumn('systemtagid', 'integer', [
741
+                'notnull' => true,
742
+                'length' => 4,
743
+                'default' => 0,
744
+                'unsigned' => true,
745
+            ]);
746
+            $table->setPrimaryKey(['objecttype', 'objectid', 'systemtagid'], 'som_pk');
747 747
 //			$table->addUniqueIndex(['objecttype', 'objectid', 'systemtagid'], 'mapping');
748
-		}
748
+        }
749 749
 
750
-		if (!$schema->hasTable('systemtag_group')) {
751
-			$table = $schema->createTable('systemtag_group');
752
-			$table->addColumn('systemtagid', 'integer', [
753
-				'notnull' => true,
754
-				'length' => 4,
755
-				'default' => 0,
756
-				'unsigned' => true,
757
-			]);
758
-			$table->addColumn('gid', 'string', [
759
-				'notnull' => true,
760
-			]);
761
-			$table->setPrimaryKey(['gid', 'systemtagid']);
762
-		}
750
+        if (!$schema->hasTable('systemtag_group')) {
751
+            $table = $schema->createTable('systemtag_group');
752
+            $table->addColumn('systemtagid', 'integer', [
753
+                'notnull' => true,
754
+                'length' => 4,
755
+                'default' => 0,
756
+                'unsigned' => true,
757
+            ]);
758
+            $table->addColumn('gid', 'string', [
759
+                'notnull' => true,
760
+            ]);
761
+            $table->setPrimaryKey(['gid', 'systemtagid']);
762
+        }
763 763
 
764
-		if (!$schema->hasTable('file_locks')) {
765
-			$table = $schema->createTable('file_locks');
766
-			$table->addColumn('id', 'integer', [
767
-				'autoincrement' => true,
768
-				'notnull' => true,
769
-				'length' => 4,
770
-				'unsigned' => true,
771
-			]);
772
-			$table->addColumn('lock', 'integer', [
773
-				'notnull' => true,
774
-				'length' => 4,
775
-				'default' => 0,
776
-			]);
777
-			$table->addColumn('key', 'string', [
778
-				'notnull' => true,
779
-				'length' => 64,
780
-			]);
781
-			$table->addColumn('ttl', 'integer', [
782
-				'notnull' => true,
783
-				'length' => 4,
784
-				'default' => -1,
785
-			]);
786
-			$table->setPrimaryKey(['id']);
787
-			$table->addUniqueIndex(['key'], 'lock_key_index');
788
-			$table->addIndex(['ttl'], 'lock_ttl_index');
789
-		}
764
+        if (!$schema->hasTable('file_locks')) {
765
+            $table = $schema->createTable('file_locks');
766
+            $table->addColumn('id', 'integer', [
767
+                'autoincrement' => true,
768
+                'notnull' => true,
769
+                'length' => 4,
770
+                'unsigned' => true,
771
+            ]);
772
+            $table->addColumn('lock', 'integer', [
773
+                'notnull' => true,
774
+                'length' => 4,
775
+                'default' => 0,
776
+            ]);
777
+            $table->addColumn('key', 'string', [
778
+                'notnull' => true,
779
+                'length' => 64,
780
+            ]);
781
+            $table->addColumn('ttl', 'integer', [
782
+                'notnull' => true,
783
+                'length' => 4,
784
+                'default' => -1,
785
+            ]);
786
+            $table->setPrimaryKey(['id']);
787
+            $table->addUniqueIndex(['key'], 'lock_key_index');
788
+            $table->addIndex(['ttl'], 'lock_ttl_index');
789
+        }
790 790
 
791
-		if (!$schema->hasTable('comments')) {
792
-			$table = $schema->createTable('comments');
793
-			$table->addColumn('id', 'integer', [
794
-				'autoincrement' => true,
795
-				'notnull' => true,
796
-				'length' => 4,
797
-				'unsigned' => true,
798
-			]);
799
-			$table->addColumn('parent_id', 'integer', [
800
-				'notnull' => true,
801
-				'length' => 4,
802
-				'default' => 0,
803
-				'unsigned' => true,
804
-			]);
805
-			$table->addColumn('topmost_parent_id', 'integer', [
806
-				'notnull' => true,
807
-				'length' => 4,
808
-				'default' => 0,
809
-				'unsigned' => true,
810
-			]);
811
-			$table->addColumn('children_count', 'integer', [
812
-				'notnull' => true,
813
-				'length' => 4,
814
-				'default' => 0,
815
-				'unsigned' => true,
816
-			]);
817
-			$table->addColumn('actor_type', 'string', [
818
-				'notnull' => true,
819
-				'length' => 64,
820
-				'default' => '',
821
-			]);
822
-			$table->addColumn('actor_id', 'string', [
823
-				'notnull' => true,
824
-				'length' => 64,
825
-				'default' => '',
826
-			]);
827
-			$table->addColumn('message', 'text', [
828
-				'notnull' => false,
829
-			]);
830
-			$table->addColumn('verb', 'string', [
831
-				'notnull' => false,
832
-				'length' => 64,
833
-			]);
834
-			$table->addColumn('creation_timestamp', 'datetime', [
835
-				'notnull' => false,
836
-			]);
837
-			$table->addColumn('latest_child_timestamp', 'datetime', [
838
-				'notnull' => false,
839
-			]);
840
-			$table->addColumn('object_type', 'string', [
841
-				'notnull' => true,
842
-				'length' => 64,
843
-				'default' => '',
844
-			]);
845
-			$table->addColumn('object_id', 'string', [
846
-				'notnull' => true,
847
-				'length' => 64,
848
-				'default' => '',
849
-			]);
850
-			$table->addColumn('reference_id', 'string', [
851
-				'notnull' => false,
852
-				'length' => 64,
853
-			]);
854
-			$table->setPrimaryKey(['id']);
855
-			$table->addIndex(['parent_id'], 'comments_parent_id_index');
856
-			$table->addIndex(['topmost_parent_id'], 'comments_topmost_parent_id_idx');
857
-			$table->addIndex(['object_type', 'object_id', 'creation_timestamp'], 'comments_object_index');
858
-			$table->addIndex(['actor_type', 'actor_id'], 'comments_actor_index');
859
-		}
791
+        if (!$schema->hasTable('comments')) {
792
+            $table = $schema->createTable('comments');
793
+            $table->addColumn('id', 'integer', [
794
+                'autoincrement' => true,
795
+                'notnull' => true,
796
+                'length' => 4,
797
+                'unsigned' => true,
798
+            ]);
799
+            $table->addColumn('parent_id', 'integer', [
800
+                'notnull' => true,
801
+                'length' => 4,
802
+                'default' => 0,
803
+                'unsigned' => true,
804
+            ]);
805
+            $table->addColumn('topmost_parent_id', 'integer', [
806
+                'notnull' => true,
807
+                'length' => 4,
808
+                'default' => 0,
809
+                'unsigned' => true,
810
+            ]);
811
+            $table->addColumn('children_count', 'integer', [
812
+                'notnull' => true,
813
+                'length' => 4,
814
+                'default' => 0,
815
+                'unsigned' => true,
816
+            ]);
817
+            $table->addColumn('actor_type', 'string', [
818
+                'notnull' => true,
819
+                'length' => 64,
820
+                'default' => '',
821
+            ]);
822
+            $table->addColumn('actor_id', 'string', [
823
+                'notnull' => true,
824
+                'length' => 64,
825
+                'default' => '',
826
+            ]);
827
+            $table->addColumn('message', 'text', [
828
+                'notnull' => false,
829
+            ]);
830
+            $table->addColumn('verb', 'string', [
831
+                'notnull' => false,
832
+                'length' => 64,
833
+            ]);
834
+            $table->addColumn('creation_timestamp', 'datetime', [
835
+                'notnull' => false,
836
+            ]);
837
+            $table->addColumn('latest_child_timestamp', 'datetime', [
838
+                'notnull' => false,
839
+            ]);
840
+            $table->addColumn('object_type', 'string', [
841
+                'notnull' => true,
842
+                'length' => 64,
843
+                'default' => '',
844
+            ]);
845
+            $table->addColumn('object_id', 'string', [
846
+                'notnull' => true,
847
+                'length' => 64,
848
+                'default' => '',
849
+            ]);
850
+            $table->addColumn('reference_id', 'string', [
851
+                'notnull' => false,
852
+                'length' => 64,
853
+            ]);
854
+            $table->setPrimaryKey(['id']);
855
+            $table->addIndex(['parent_id'], 'comments_parent_id_index');
856
+            $table->addIndex(['topmost_parent_id'], 'comments_topmost_parent_id_idx');
857
+            $table->addIndex(['object_type', 'object_id', 'creation_timestamp'], 'comments_object_index');
858
+            $table->addIndex(['actor_type', 'actor_id'], 'comments_actor_index');
859
+        }
860 860
 
861
-		if (!$schema->hasTable('comments_read_markers')) {
862
-			$table = $schema->createTable('comments_read_markers');
863
-			$table->addColumn('user_id', 'string', [
864
-				'notnull' => true,
865
-				'length' => 64,
866
-				'default' => '',
867
-			]);
868
-			$table->addColumn('marker_datetime', 'datetime', [
869
-				'notnull' => false,
870
-			]);
871
-			$table->addColumn('object_type', 'string', [
872
-				'notnull' => true,
873
-				'length' => 64,
874
-				'default' => '',
875
-			]);
876
-			$table->addColumn('object_id', 'string', [
877
-				'notnull' => true,
878
-				'length' => 64,
879
-				'default' => '',
880
-			]);
881
-			$table->addIndex(['object_type', 'object_id'], 'comments_marker_object_index');
882
-			$table->setPrimaryKey(['user_id', 'object_type', 'object_id'], 'crm_pk');
861
+        if (!$schema->hasTable('comments_read_markers')) {
862
+            $table = $schema->createTable('comments_read_markers');
863
+            $table->addColumn('user_id', 'string', [
864
+                'notnull' => true,
865
+                'length' => 64,
866
+                'default' => '',
867
+            ]);
868
+            $table->addColumn('marker_datetime', 'datetime', [
869
+                'notnull' => false,
870
+            ]);
871
+            $table->addColumn('object_type', 'string', [
872
+                'notnull' => true,
873
+                'length' => 64,
874
+                'default' => '',
875
+            ]);
876
+            $table->addColumn('object_id', 'string', [
877
+                'notnull' => true,
878
+                'length' => 64,
879
+                'default' => '',
880
+            ]);
881
+            $table->addIndex(['object_type', 'object_id'], 'comments_marker_object_index');
882
+            $table->setPrimaryKey(['user_id', 'object_type', 'object_id'], 'crm_pk');
883 883
 //			$table->addUniqueIndex(['user_id', 'object_type', 'object_id'], 'comments_marker_index');
884
-		}
884
+        }
885 885
 
886 886
 //		if (!$schema->hasTable('credentials')) {
887 887
 //			$table = $schema->createTable('credentials');
@@ -900,139 +900,139 @@  discard block
 block discarded – undo
900 900
 //			$table->addIndex(['user'], 'credentials_user');
901 901
 //		}
902 902
 
903
-		if (!$schema->hasTable('admin_sections')) {
904
-			$table = $schema->createTable('admin_sections');
905
-			$table->addColumn('id', 'string', [
906
-				'notnull' => true,
907
-				'length' => 64,
908
-			]);
909
-			$table->addColumn('class', 'string', [
910
-				'notnull' => true,
911
-				'length' => 255,
912
-				'default' => '',
913
-			]);
914
-			$table->addColumn('priority', 'smallint', [
915
-				'notnull' => true,
916
-				'length' => 1,
917
-				'default' => 0,
918
-			]);
919
-			$table->setPrimaryKey(['id']);
920
-			$table->addUniqueIndex(['class'], 'admin_sections_class');
921
-		}
903
+        if (!$schema->hasTable('admin_sections')) {
904
+            $table = $schema->createTable('admin_sections');
905
+            $table->addColumn('id', 'string', [
906
+                'notnull' => true,
907
+                'length' => 64,
908
+            ]);
909
+            $table->addColumn('class', 'string', [
910
+                'notnull' => true,
911
+                'length' => 255,
912
+                'default' => '',
913
+            ]);
914
+            $table->addColumn('priority', 'smallint', [
915
+                'notnull' => true,
916
+                'length' => 1,
917
+                'default' => 0,
918
+            ]);
919
+            $table->setPrimaryKey(['id']);
920
+            $table->addUniqueIndex(['class'], 'admin_sections_class');
921
+        }
922 922
 
923
-		if (!$schema->hasTable('admin_settings')) {
924
-			$table = $schema->createTable('admin_settings');
925
-			$table->addColumn('id', 'integer', [
926
-				'autoincrement' => true,
927
-				'notnull' => true,
928
-				'length' => 4,
929
-			]);
930
-			$table->addColumn('class', 'string', [
931
-				'notnull' => true,
932
-				'length' => 255,
933
-				'default' => '',
934
-			]);
935
-			$table->addColumn('section', 'string', [
936
-				'notnull' => false,
937
-				'length' => 64,
938
-			]);
939
-			$table->addColumn('priority', 'smallint', [
940
-				'notnull' => true,
941
-				'length' => 1,
942
-				'default' => 0,
943
-			]);
944
-			$table->setPrimaryKey(['id']);
945
-			$table->addUniqueIndex(['class'], 'admin_settings_class');
946
-			$table->addIndex(['section'], 'admin_settings_section');
947
-		}
923
+        if (!$schema->hasTable('admin_settings')) {
924
+            $table = $schema->createTable('admin_settings');
925
+            $table->addColumn('id', 'integer', [
926
+                'autoincrement' => true,
927
+                'notnull' => true,
928
+                'length' => 4,
929
+            ]);
930
+            $table->addColumn('class', 'string', [
931
+                'notnull' => true,
932
+                'length' => 255,
933
+                'default' => '',
934
+            ]);
935
+            $table->addColumn('section', 'string', [
936
+                'notnull' => false,
937
+                'length' => 64,
938
+            ]);
939
+            $table->addColumn('priority', 'smallint', [
940
+                'notnull' => true,
941
+                'length' => 1,
942
+                'default' => 0,
943
+            ]);
944
+            $table->setPrimaryKey(['id']);
945
+            $table->addUniqueIndex(['class'], 'admin_settings_class');
946
+            $table->addIndex(['section'], 'admin_settings_section');
947
+        }
948 948
 
949
-		if (!$schema->hasTable('personal_sections')) {
950
-			$table = $schema->createTable('personal_sections');
951
-			$table->addColumn('id', 'string', [
952
-				'notnull' => true,
953
-				'length' => 64,
954
-			]);
955
-			$table->addColumn('class', 'string', [
956
-				'notnull' => true,
957
-				'length' => 255,
958
-				'default' => '',
959
-			]);
960
-			$table->addColumn('priority', 'smallint', [
961
-				'notnull' => true,
962
-				'length' => 1,
963
-				'default' => 0,
964
-			]);
965
-			$table->setPrimaryKey(['id']);
966
-			$table->addUniqueIndex(['class'], 'personal_sections_class');
967
-		}
949
+        if (!$schema->hasTable('personal_sections')) {
950
+            $table = $schema->createTable('personal_sections');
951
+            $table->addColumn('id', 'string', [
952
+                'notnull' => true,
953
+                'length' => 64,
954
+            ]);
955
+            $table->addColumn('class', 'string', [
956
+                'notnull' => true,
957
+                'length' => 255,
958
+                'default' => '',
959
+            ]);
960
+            $table->addColumn('priority', 'smallint', [
961
+                'notnull' => true,
962
+                'length' => 1,
963
+                'default' => 0,
964
+            ]);
965
+            $table->setPrimaryKey(['id']);
966
+            $table->addUniqueIndex(['class'], 'personal_sections_class');
967
+        }
968 968
 
969
-		if (!$schema->hasTable('personal_settings')) {
970
-			$table = $schema->createTable('personal_settings');
971
-			$table->addColumn('id', 'integer', [
972
-				'autoincrement' => true,
973
-				'notnull' => true,
974
-				'length' => 4,
975
-			]);
976
-			$table->addColumn('class', 'string', [
977
-				'notnull' => true,
978
-				'length' => 255,
979
-				'default' => '',
980
-			]);
981
-			$table->addColumn('section', 'string', [
982
-				'notnull' => false,
983
-				'length' => 64,
984
-			]);
985
-			$table->addColumn('priority', 'smallint', [
986
-				'notnull' => true,
987
-				'length' => 1,
988
-				'default' => 0,
989
-			]);
990
-			$table->setPrimaryKey(['id']);
991
-			$table->addUniqueIndex(['class'], 'personal_settings_class');
992
-			$table->addIndex(['section'], 'personal_settings_section');
993
-		}
969
+        if (!$schema->hasTable('personal_settings')) {
970
+            $table = $schema->createTable('personal_settings');
971
+            $table->addColumn('id', 'integer', [
972
+                'autoincrement' => true,
973
+                'notnull' => true,
974
+                'length' => 4,
975
+            ]);
976
+            $table->addColumn('class', 'string', [
977
+                'notnull' => true,
978
+                'length' => 255,
979
+                'default' => '',
980
+            ]);
981
+            $table->addColumn('section', 'string', [
982
+                'notnull' => false,
983
+                'length' => 64,
984
+            ]);
985
+            $table->addColumn('priority', 'smallint', [
986
+                'notnull' => true,
987
+                'length' => 1,
988
+                'default' => 0,
989
+            ]);
990
+            $table->setPrimaryKey(['id']);
991
+            $table->addUniqueIndex(['class'], 'personal_settings_class');
992
+            $table->addIndex(['section'], 'personal_settings_section');
993
+        }
994 994
 
995
-		if (!$schema->hasTable('accounts')) {
996
-			$table = $schema->createTable('accounts');
997
-			$table->addColumn('uid', 'string', [
998
-				'notnull' => true,
999
-				'length' => 64,
1000
-				'default' => '',
1001
-			]);
1002
-			$table->addColumn('data', 'text', [
1003
-				'notnull' => true,
1004
-				'default' => '',
1005
-			]);
1006
-			$table->setPrimaryKey(['uid']);
1007
-		}
1008
-		return $schema;
1009
-	}
995
+        if (!$schema->hasTable('accounts')) {
996
+            $table = $schema->createTable('accounts');
997
+            $table->addColumn('uid', 'string', [
998
+                'notnull' => true,
999
+                'length' => 64,
1000
+                'default' => '',
1001
+            ]);
1002
+            $table->addColumn('data', 'text', [
1003
+                'notnull' => true,
1004
+                'default' => '',
1005
+            ]);
1006
+            $table->setPrimaryKey(['uid']);
1007
+        }
1008
+        return $schema;
1009
+    }
1010 1010
 
1011
-	public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
1012
-		/** @var ISchemaWrapper $schema */
1013
-		$schema = $schemaClosure();
1014
-		if (!$schema->hasTable('dav_properties')) {
1015
-			return;
1016
-		}
1017
-		$query = $this->connection->getQueryBuilder();
1018
-		$query->select('*')
1019
-			->from('dav_properties');
1011
+    public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
1012
+        /** @var ISchemaWrapper $schema */
1013
+        $schema = $schemaClosure();
1014
+        if (!$schema->hasTable('dav_properties')) {
1015
+            return;
1016
+        }
1017
+        $query = $this->connection->getQueryBuilder();
1018
+        $query->select('*')
1019
+            ->from('dav_properties');
1020 1020
 
1021
-		$insert = $this->connection->getQueryBuilder();
1022
-		$insert->insert('properties')
1023
-			->setValue('propertypath', $insert->createParameter('propertypath'))
1024
-			->setValue('propertyname', $insert->createParameter('propertyname'))
1025
-			->setValue('propertyvalue', $insert->createParameter('propertyvalue'))
1026
-			->setValue('userid', $insert->createParameter('userid'));
1021
+        $insert = $this->connection->getQueryBuilder();
1022
+        $insert->insert('properties')
1023
+            ->setValue('propertypath', $insert->createParameter('propertypath'))
1024
+            ->setValue('propertyname', $insert->createParameter('propertyname'))
1025
+            ->setValue('propertyvalue', $insert->createParameter('propertyvalue'))
1026
+            ->setValue('userid', $insert->createParameter('userid'));
1027 1027
 
1028
-		$result = $query->execute();
1029
-		while ($row = $result->fetch()) {
1030
-			preg_match('/(calendar)\/([A-z0-9-@_]+)\//', $row['propertypath'], $match);
1031
-			$insert->setParameter('propertypath', (string) $row['propertypath'])
1032
-				->setParameter('propertyname', (string) $row['propertyname'])
1033
-				->setParameter('propertyvalue', (string) $row['propertyvalue'])
1034
-				->setParameter('userid', ($match[2] ?? ''));
1035
-			$insert->execute();
1036
-		}
1037
-	}
1028
+        $result = $query->execute();
1029
+        while ($row = $result->fetch()) {
1030
+            preg_match('/(calendar)\/([A-z0-9-@_]+)\//', $row['propertypath'], $match);
1031
+            $insert->setParameter('propertypath', (string) $row['propertypath'])
1032
+                ->setParameter('propertyname', (string) $row['propertyname'])
1033
+                ->setParameter('propertyvalue', (string) $row['propertyvalue'])
1034
+                ->setParameter('userid', ($match[2] ?? ''));
1035
+            $insert->execute();
1036
+        }
1037
+    }
1038 1038
 }
Please login to merge, or discard this patch.