Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Version16000Date20190207141427.php 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 OC\Core\Migrations;
  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 Version16000Date20190207141427 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('collres_collections')) {
  24. $table = $schema->createTable('collres_collections');
  25. $table->addColumn('id', Types::BIGINT, [
  26. 'autoincrement' => true,
  27. 'notnull' => true,
  28. ]);
  29. $table->addColumn('name', Types::STRING, [
  30. 'notnull' => true,
  31. 'length' => 64,
  32. ]);
  33. $table->setPrimaryKey(['id']);
  34. }
  35. if (!$schema->hasTable('collres_resources')) {
  36. $table = $schema->createTable('collres_resources');
  37. $table->addColumn('collection_id', Types::BIGINT, [
  38. 'notnull' => true,
  39. ]);
  40. $table->addColumn('resource_type', Types::STRING, [
  41. 'notnull' => true,
  42. 'length' => 64,
  43. ]);
  44. $table->addColumn('resource_id', Types::STRING, [
  45. 'notnull' => true,
  46. 'length' => 64,
  47. ]);
  48. $table->setPrimaryKey(['collection_id', 'resource_type', 'resource_id'], 'crr_pk');
  49. // $table->addUniqueIndex(['collection_id', 'resource_type', 'resource_id'], 'collres_unique_res');
  50. }
  51. if (!$schema->hasTable('collres_accesscache')) {
  52. $table = $schema->createTable('collres_accesscache');
  53. $table->addColumn('user_id', Types::STRING, [
  54. 'notnull' => true,
  55. 'length' => 64,
  56. ]);
  57. $table->addColumn('collection_id', Types::BIGINT, [
  58. 'notnull' => false,
  59. 'default' => 0,
  60. ]);
  61. $table->addColumn('resource_type', Types::STRING, [
  62. 'notnull' => false,
  63. 'length' => 64,
  64. 'default' => '',
  65. ]);
  66. $table->addColumn('resource_id', Types::STRING, [
  67. 'notnull' => false,
  68. 'length' => 64,
  69. 'default' => '',
  70. ]);
  71. $table->addColumn('access', Types::SMALLINT, [
  72. 'notnull' => false,
  73. 'default' => 0,
  74. ]);
  75. $table->setPrimaryKey(['user_id', 'collection_id', 'resource_type', 'resource_id'], 'cra_pk');
  76. // $table->addUniqueIndex(['user_id', 'collection_id', 'resource_type', 'resource_id'], 'collres_unique_user');
  77. $table->addIndex(['user_id', 'resource_type', 'resource_id'], 'collres_user_res');
  78. $table->addIndex(['user_id', 'collection_id'], 'collres_user_coll');
  79. }
  80. return $schema;
  81. }
  82. }