1
0

Version1005Date20180530124431.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCA\DAV\Migration;
  7. use OCP\DB\ISchemaWrapper;
  8. use OCP\DB\Types;
  9. use OCP\Migration\IOutput;
  10. use OCP\Migration\SimpleMigrationStep;
  11. class Version1005Date20180530124431 extends SimpleMigrationStep {
  12. /**
  13. * @param IOutput $output
  14. * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  15. * @param array $options
  16. * @return null|ISchemaWrapper
  17. * @since 13.0.0
  18. */
  19. public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
  20. /** @var ISchemaWrapper $schema */
  21. $schema = $schemaClosure();
  22. $types = ['resources', 'rooms'];
  23. foreach ($types as $type) {
  24. if (!$schema->hasTable('calendar_' . $type)) {
  25. $table = $schema->createTable('calendar_' . $type);
  26. $table->addColumn('id', Types::BIGINT, [
  27. 'autoincrement' => true,
  28. 'notnull' => true,
  29. 'length' => 11,
  30. 'unsigned' => true,
  31. ]);
  32. $table->addColumn('backend_id', Types::STRING, [
  33. 'notnull' => false,
  34. 'length' => 64,
  35. ]);
  36. $table->addColumn('resource_id', Types::STRING, [
  37. 'notnull' => false,
  38. 'length' => 64,
  39. ]);
  40. $table->addColumn('email', Types::STRING, [
  41. 'notnull' => false,
  42. 'length' => 255,
  43. ]);
  44. $table->addColumn('displayname', Types::STRING, [
  45. 'notnull' => false,
  46. 'length' => 255,
  47. ]);
  48. $table->addColumn('group_restrictions', Types::STRING, [
  49. 'notnull' => false,
  50. 'length' => 4000,
  51. ]);
  52. $table->setPrimaryKey(['id']);
  53. $table->addIndex(['backend_id', 'resource_id'], 'calendar_' . $type . '_bkdrsc');
  54. $table->addIndex(['email'], 'calendar_' . $type . '_email');
  55. $table->addIndex(['displayname'], 'calendar_' . $type . '_name');
  56. }
  57. }
  58. return $schema;
  59. }
  60. }