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