1
0

Version1010Date20200630191302.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Federation\Migration;
  8. use Closure;
  9. use OCP\DB\ISchemaWrapper;
  10. use OCP\DB\Types;
  11. use OCP\Migration\IOutput;
  12. use OCP\Migration\SimpleMigrationStep;
  13. class Version1010Date20200630191302 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) {
  21. /** @var ISchemaWrapper $schema */
  22. $schema = $schemaClosure();
  23. if (!$schema->hasTable('trusted_servers')) {
  24. $table = $schema->createTable('trusted_servers');
  25. $table->addColumn('id', Types::INTEGER, [
  26. 'autoincrement' => true,
  27. 'notnull' => true,
  28. 'length' => 4,
  29. ]);
  30. $table->addColumn('url', Types::STRING, [
  31. 'notnull' => true,
  32. 'length' => 512,
  33. ]);
  34. $table->addColumn('url_hash', Types::STRING, [
  35. 'notnull' => true,
  36. 'default' => '',
  37. ]);
  38. $table->addColumn('token', Types::STRING, [
  39. 'notnull' => false,
  40. 'length' => 128,
  41. ]);
  42. $table->addColumn('shared_secret', Types::STRING, [
  43. 'notnull' => false,
  44. 'length' => 256,
  45. ]);
  46. $table->addColumn('status', Types::INTEGER, [
  47. 'notnull' => true,
  48. 'length' => 4,
  49. 'default' => 2,
  50. ]);
  51. $table->addColumn('sync_token', Types::STRING, [
  52. 'notnull' => false,
  53. 'length' => 512,
  54. ]);
  55. $table->setPrimaryKey(['id']);
  56. $table->addUniqueIndex(['url_hash'], 'url_hash');
  57. }
  58. return $schema;
  59. }
  60. }