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.

Version21000Date20210309185126.php 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2021 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 Doctrine\DBAL\Types\Types;
  10. use OCP\DB\ISchemaWrapper;
  11. use OCP\Migration\IOutput;
  12. use OCP\Migration\SimpleMigrationStep;
  13. class Version21000Date20210309185126 extends SimpleMigrationStep {
  14. /**
  15. * @param IOutput $output
  16. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  17. * @param array $options
  18. * @return null|ISchemaWrapper
  19. */
  20. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
  21. /** @var ISchemaWrapper $schema */
  22. $schema = $schemaClosure();
  23. if (!$schema->hasTable('known_users')) {
  24. $table = $schema->createTable('known_users');
  25. // Auto increment id
  26. $table->addColumn('id', Types::BIGINT, [
  27. 'autoincrement' => true,
  28. 'notnull' => true,
  29. ]);
  30. $table->addColumn('known_to', Types::STRING, [
  31. 'notnull' => true,
  32. 'length' => 255,
  33. ]);
  34. $table->addColumn('known_user', Types::STRING, [
  35. 'notnull' => true,
  36. 'length' => 255,
  37. ]);
  38. $table->setPrimaryKey(['id']);
  39. $table->addIndex(['known_to'], 'ku_known_to');
  40. return $schema;
  41. }
  42. return null;
  43. }
  44. }