Version010402Date20190107124745.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\OAuth2\Migration;
  8. use Closure;
  9. use OCP\DB\ISchemaWrapper;
  10. use OCP\Migration\IOutput;
  11. use OCP\Migration\SimpleMigrationStep;
  12. class Version010402Date20190107124745 extends SimpleMigrationStep {
  13. /**
  14. * @param IOutput $output
  15. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  16. * @param array $options
  17. * @return null|ISchemaWrapper
  18. */
  19. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
  20. /** @var ISchemaWrapper $schema */
  21. $schema = $schemaClosure();
  22. // During an ownCloud migration, the client_identifier column identifier might not exist yet.
  23. if ($schema->getTable('oauth2_clients')->hasColumn('client_identifier')) {
  24. $table = $schema->getTable('oauth2_clients');
  25. $table->dropIndex('oauth2_client_id_idx');
  26. $table->addUniqueIndex(['client_identifier'], 'oauth2_client_id_idx');
  27. return $schema;
  28. }
  29. }
  30. }