You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Version28000Date20230803221055.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\Core\Migrations;
  8. use Closure;
  9. use OCP\DB\ISchemaWrapper;
  10. use OCP\Migration\IOutput;
  11. use OCP\Migration\SimpleMigrationStep;
  12. /**
  13. * Adjust textprocessing_tasks table
  14. */
  15. class Version28000Date20230803221055 extends SimpleMigrationStep {
  16. /**
  17. * @param IOutput $output
  18. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  19. * @param array $options
  20. * @return null|ISchemaWrapper
  21. */
  22. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
  23. /** @var ISchemaWrapper $schema */
  24. $schema = $schemaClosure();
  25. $changed = false;
  26. if ($schema->hasTable('textprocessing_tasks')) {
  27. $table = $schema->getTable('textprocessing_tasks');
  28. $column = $table->getColumn('user_id');
  29. $column->setNotnull(false);
  30. if (!$table->hasIndex('tp_tasks_uid_appid_ident')) {
  31. $table->addIndex(['user_id', 'app_id', 'identifier'], 'tp_tasks_uid_appid_ident');
  32. $changed = true;
  33. }
  34. }
  35. if ($changed) {
  36. return $schema;
  37. }
  38. return null;
  39. }
  40. }